Sorting a Secondary Datasource - InfoPath Dev
in

InfoPath Dev

Sorting a Secondary Datasource

Last post 05-20-2005 04:18 PM by Greg Collins. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-19-2005 02:07 PM

    • Idisis
    • Not Ranked
    • Joined on 04-28-2005
    • Posts 5

    Sorting a Secondary Datasource

    Hello All,

    I am looping through a list of strings from a secondary datasource and I cant seem to figure out a way to sort the items without writing my own function to do so. What I am wondering is if there is anyway to sort for a secondary data source when you read from it, much in the same way you place a where statement when you read from it. Here is my code:

    var sDataObj = XDocument.DataObjects["Component Procedures"].DOM;

    sDataObj.setProperty("SelectionNamespaces","xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution' xmlns:dsf='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution'");

    var nodeList = sDataObj.selectNodes("/dfs:myFields/dfs:dataFields/dsf:Component_Procedures[@Version='" + version.text + "' and @Component='" + comp_name.text + "']");

    What I would like to do is order this by a field call Procedure.

    Any suggestions? I know there is always the option of manually checking the whole data set and comparing to do the sorting, but I would rather use an in-built query to make it more efficient.

    Thanks,
    Ryan
  • 05-20-2005 04:11 PM In reply to

    Re: Sorting a Secondary Datasource

    Sorting ... sure, we do it all the time. Even the Samples have an example of two of sorting using jscript. In general, you need to create a separate secondary DOM to insert your elements into or create an index in your main DOM into the secondary DOM. Sounds like you want to do an xsl sort though, which is also possible but has to be defined in the xsl via the filter. Greg will have more info.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 05-20-2005 04:18 PM In reply to

    Re: Sorting a Secondary Datasource

    This depends on your data source.

    If you have a database, you can simple tell the database to sort before delivering you the data. You can edit the SQL and add an ORDER BY clause in there.

    If you have an XML or other source, you can physically sort it using code, or you can create an XSL that sorts the data and use the results of the transform to overwrite your original source (probably faster than using a code sort).

    Or you can use a preserve code block in the view and add in an xsl:sort command. If you are familiar with preserve code blocks, this shouldn't be too hard. If not, you'll have to do some research and play aroud a bit.

    Greg Collins [InfoPath MVP]
    InfoPathDev
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.