Sort a repeating table in 'Asset tracking sample' - InfoPath Dev
in

InfoPath Dev

Sort a repeating table in 'Asset tracking sample'

Last post 09-21-2006 12:24 AM by Patrick Halstead. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 09-20-2006 02:44 AM

    Sort a repeating table in 'Asset tracking sample'

    Hello,

    I have looked at the example in the out-of-box solution for Asset Tracking (Asset tracking form.XSN) and I really would like to use the approach of dynamically sorting a repeated table.
    I have tried to get it working half the night but I failed by now ;-((

    Now I hope that someone can explain me the use of the code. My problem is the function 'compareAssets' in the following code:

    I don“t know where I can define the parameters of the function --- in this case xmlAssetLeft and xmlAssetRight

    function compareAssets(xmlAssetLeft, xmlAssetRight)
    {
    var xmlLeft = xmlAssetLeft.selectSingleNode(g_xpathSortBy);
    var xmlRight = xmlAssetRight.selectSingleNode(g_xpathSortBy);

    var valueLeft = getValue(xmlLeft);
    var valueRight = getValue(xmlRight);

    if ((valueLeft < valueRight) || (typeof(valueLeft) == "number" && typeof(valueRight) == "string"))
    return -1;
    else if ((valueLeft > valueRight) || (typeof(valueLeft) == "string" && typeof(valueRight) == "number"))
    return 1;
    else
    return 0;
    }
    I have searched the whole script code for xmlAssetLeft and xmlAssetRight but the only place where they are used are in this function.

    Does anyone know this sample in detail and can help me to understand this.

    Thank you very much in advance
    Karsten
  • 09-21-2006 12:24 AM In reply to

    Re: Sort a repeating table in 'Asset tracking sample'

    Hi Karsten,
    Greg wrote this code ~6 years ago and I reviewed it while still at MS. Search for the sort function. It takes compareAssets as a function argument and passes two items from the index. Hopefully, that's enough info, but if not, I'm sure Greg will respond with more details soon... :)
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.