jQuery UI Widgets Forums TreeGrid Sorting and Row Position

This topic contains 14 replies, has 3 voices, and was last updated by  Goga 7 years, 9 months ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
  • Sorting and Row Position #70807

    tdemeo
    Participant

    I’m trying to determine whether a given row is in the first or last position in the tree grid display. I am able to do this by evaluating $(“#treeGrid”).jqxTreeGrid(‘getRows’) and comparing my row id to the row id of the first and last array elements.

    However, when I use a column sort, $(“#treeGrid”).jqxTreeGrid(‘getRows’) returns the rows in exactly the same order as before the sort. Is there any way to evaluate row ordering after a column sort?

    Sorting and Row Position #70812

    Peter Stoev
    Keymaster

    Hi tdemeo,

    There is no method for that in jqxTreeGrid. The rendered rows and bound rows are different things and the rendered rows are built internally and displayed to the users. getRows returns the Array of rows loaded in the widget from its data source i.e it may not match the rendering order.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Sorting and Row Position #92871

    Goga
    Participant

    Hello.

    Interesting bug, after sorting programmatically work with the TreeGrid is impossible.
    This bug is fixed or there is a workaround?

    Best Regards
    Goga

    Sorting and Row Position #92872

    Peter Stoev
    Keymaster

    Hi Goga,

    I do not think that there is any bug here and I find your post a bit irrelevant to the topic.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Sorting and Row Position #92874

    Goga
    Participant

    Hi Peter.

    Why irrelevant the topic? I was faced with the same problem.

    In the tree there is no link between the visual rows and the data source after sorting.

    For example: after sorting, there is no way (through API) to know the UID of the first visual ROW.
    It turns out that after sorting it is not possible to work programmatically with TreeGrid.

    Best Regards
    Goga

    Sorting and Row Position #92875

    Peter Stoev
    Keymaster

    Hi Goga,

    There is API in the TreeGrid which allows you to get the rows so you can work programatically with it

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Sorting and Row Position #92876

    Goga
    Participant

    Hi Peter.

    It’s great, apparently I was not careful.
    Peter, please tell me how to get the UID first visual row after sorting?

    Best Regards
    Goga

    Sorting and Row Position #92884

    Peter Stoev
    Keymaster

    Use getRows method of the TreeGrid. It returns the ROWS loaded in the TreeGrid. It is not affected by Sorting. Example: http://jsfiddle.net/ot3j6575/

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Sorting and Row Position #92888

    Goga
    Participant

    it’s your incorrect example of work:
    2 Andrew Fuller
    8 Laura Callahan
    1 Nancy Davolio
    3 Janet Leverling
    4 Margaret Peacock
    5 Steven Buchanan
    6 Michael Suyama
    7 Robert King
    9 Anne Dodsworth

    if I get the UID of second (or 3, 4, 5 and etc.) visual row I will get the incorrect value:
    – for seconr row I get UID=8, and the correct value = 5

    Sorting and Row Position #92891

    Peter Stoev
    Keymaster

    Goga. Results are exactly as they should be. UID is not Visual ID. It seems that you misunderstood what getRows returns or do not read my posts.
    ” It returns the ROWS loaded in the TreeGrid. It is not affected by Sorting” This means that getRows always returns the same array of rows and SORTING does not affect the results. Hope it is clear now.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Sorting and Row Position #92893

    Goga
    Participant

    I repeat my question:

    how to get the UID first (second, and etc.) visual row after sorting?

    I can’t perform a basic task:
    – after downloading data from the server I need to sort the TreeGrid and select the first row

    Sorting and Row Position #92895

    Peter Stoev
    Keymaster

    The Selection in the TreeGrid is by UID, not by Visual Row. We do not have API for getting the order of the rows

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Sorting and Row Position #92896

    Goga
    Participant

    would it be correct to take the uid in this way?

    function getUid(rowindex) {
    return $(“#jqxgrid”).find(‘#contenttablejqxgrid’).find(‘tr’).attr(‘role’, “row”).eq(rowindex).attr(‘data-key’);
    }

    Best Regards
    Goga

    Sorting and Row Position #92897

    Peter Stoev
    Keymaster

    Hi Goga,

    I think you know the answer as you are not confident in that solution. The answer is – it depends on. It depends on whether the TreeGrid has Paging enabled, it depends on whether the TreeGrid is filtered, too.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Sorting and Row Position #92898

    Goga
    Participant

    Hi Peter.

    I don’t quite understand as it may affect the filter here is working example, after applying the filter function “getUid” works correctly
    Example:

    Best Regards
    Goga

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.