Community-Credit.com | NonProfitWays.com | SOAPitstop.com   Skin:   
      User: Not logged in 
Home
Newsletter Signup
XSLT Library
Latest XML Blogs
Featured Examples
Presentations
Featured Articles
Book Chapters
Training Courses
Events
NewsGroups
 
Discussions
Examples
Tutorials
Tools
Articles
Resources
Websites
 
Sign In
My Profile
My Articles
My Examples
My Favorites
My Resources
Add a Resource
Logout
 
About Me
My Blog
HeadGeek Articles
Talking Portfolio
Resume
Pictures
World Trip Pics

Filtering Data Islands
Author: David Silverlight
Published: 5/10/2005 12:58 AM
Category: XML
Summary: This snippet demonstrates uses the "Singles Online" dating application to demonstrate some of most common functionality found in business applications. a) Filtering b) Sorting by column header (ascending or descending) and c) Highlighting the row as

 
This snippet demonstrates uses the "Taliban Singles Online" dating application to demonstrate some of most common functionality found in business applications.

a) Filtering
b) Sorting by column header (ascending or descending) and
c) Highlighting the row as the mouse moves over it. As with my other "Redneck Employee" snippet, it uses a behavior .htc file to do the highlighting and column sorting. However, this snippet also demonstrates how to use XML/XSLT to filter the data data island in the page.

Check it out in action

Note about behaviors (and how great they are):This particular implementation involves behaviors. Using behaviors, the snippet demonstrates how to add highlighting and sorting functionality without having to add alot of javascript/vbscript code each time around. Simply add the behavior to your table and the functionality comes along with it. Since I have to add this type of functionality to just about every single HTML table that I create in a web application, this saves tons of time. Well, the full sourcecode is downloadable.  However, the cliffnotes
are shown below.  The source code is documented as well and will
explain it all:

a) To add the ability to highlight the current row and "sort by clicking on the column header" you will need to simply add the behavior to the table as follows:

<TABLE style="BEHAVIOR: url(TableSortAndHighlight.htc)" ....>
b) To indication which xml attribute in the xml document is sorted when
you click on the column header, just add the "SortField" attribute
to the html table column. Examples are as follows:
<TBODY>TR><TR><TD .... SortField="FirstName" ..... <TD>State..... Yes, this assumes that the xml document is attribute normalized, but it is not a very big leap to modify to handle <BR>xml documents that are element normalized.

c) The Filtering is done via passing parameters to an XSLT file using VBScript. The code is shown below:<BR><BR>


<SCRIPT language=VBScript>
function vbFilterTable(strLocation, strOccupation, strType)

dim objXSL, objXML, objTemplate, objProcessor, strHTML
Set objXML = CreateObject("Msxml2.FreeThreadedDOMDocument")
Set objXSL = CreateObject("Msxml2.FreeThreadedDOMDocument")
'Load the XML document
objXML.async = False
objXML.Loadxml xmlDSOorig.xml
     
'Load the XSL document
objXSL.async = False
objXSL.Loadxml  xslFilter.xml
     
'Create an instance of our XSL Template object
Set objTemplate = CreateObject("MSXML2.XSLTemplate")
   
'Create an instance of our stylesheet object using our recently loaded XSLT document
Set objTemplate.stylesheet = objXSL
      
'Create an instance of our Processor object
Set objProcessor = objTemplate.createProcessor
'Define the input object for our object equal to our recently loaded XML document
objProcessor.input = objXML
'Now, finally we can add any parameters that we require to our Template processor
'In this example, we are setting the drinktype = "house" objProcessor.AddParameter "location", strLocation objProcessor.AddParameter "occupation", strOccupation objProcessor.AddParameter "type", strType       'Last but not least we do our transformation objProcessor.Transform      
'Store the results of the output into a string. strXML = objProcessor.output  
'Load up an XML DOM object from the recent XML output objXML.loadxml strXML  
'Select only the "employees" elements from our document object objXML.selectNodes("http://root")  
'Load our Data Island using our new XML object xmlDSO.loadxml  objXML.xml
end function 
  </SCRIPT>




 

 
Fans of "The Office"
Dwight Bobbleheads are here!
  “It's me! I'm the bobblehead! Yes!”



Advertise on XMLPitstop

Advertise on XMLPitstop


EggHead Cafe
Web Servicee development
DotNetSlackers
Buy text ads here!
remote online storage
Color Laser Printer
Chanel sunglasses
Skype vs. sipcall
VoIP Internettelefonie
Buy text ads here!

Interested in Text ads?
2,223 Total Members
36 members(last 30 days)
8 members(last 7 days)
2 members(today)

1,609 Total Discussions
12 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

17,260 Total Blog Posts
1,839 Blogs(last 30 days)
342 Blogs(last 7 days)
49 Blogs(today)

8,699 Newsgroup Posts
0 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

13,786 Total Resources
5 Resources(last 30 days)
1 Resources(last 7 days)
0 Resources(today)


 

David Silverlight's XMLPitstop.com| 2801 Florida Ave #225|Miami, FL 33133|Ph:305-447-1139