jQWidgets Forums

jQuery UI Widgets Forums TreeGrid Hierarchical Checkboxes determine which row was really checked / unchecked

This topic contains 7 replies, has 2 voices, and was last updated by  es3 10 years, 3 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author

  • es3
    Participant

    Hi,
    By testing the events rowCheck and rowUncheck in your example, as is:
    var args = event.args;
    var row = args.row;
    var key = args.key….
    I can see not only checked row data is being passed, but also every parent and children rows data.
    In the same way, when a row is unchecked, all parent and children rows data is also passed (if any).
    Is there any “direct / easy way” to get which row was really checked or unchecked?
    Thanks and regards


    Peter Stoev
    Keymaster

    Hi es3,

    In hierarchical checkboxes mode many rows are being checked or unchecked because checking an item affects the items parents and children. At present, there’s no event argument about which specific item was initially clicked. The information is considered to be not much important because the event is raised for each affected TreeGrid item.

    Best Regards,
    Peter Stoev

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


    es3
    Participant

    Thanks for your quick response.
    Pls, let me give a brief explanation of my purpose:
    I show hierarchical data in just 3 levels (i.e. nested categories). Every row has the same data fields and each row can be checked / unchecked independently in any level. But only one level can be checked simultaneously in the same tree of row.
    I.e.: checking a 2nd. level category in a row should uncheck its parent and its children (if checked).
    Also, each row has numerical data that performs an adition or subtraction if it has been checked or not (manual aggregates widget does not perform global operations as it adds or removes by level).
    Could this be achieved with these kind of hierarchical checkboxes?
    Thanks again!


    Peter Stoev
    Keymaster

    Hi es3,

    hierarchical checkboxes when enabled will affect every row in the hierarchy, not only a specific one. For your scenario, it would be probably better to use the default checkboxes mode and use the widget’s API to check/uncheck multiple rows if you need to do so.

    Best Regards,
    Peter Stoev

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


    es3
    Participant

    Sure, but the “partial selection” checkbox icon on top levels of Hierarchical Checkboxes it’s nice to show users that inner levels have any item(s) checked (very useful when levels are not expanded). I guess it is not possible with default checkboxes, is it?


    Peter Stoev
    Keymaster

    Hi es3,

    The default checkbox mode supports only 2 states – checked and unchecked.

    Best Regards,
    Peter Stoev

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


    es3
    Participant

    Hello again,
    Thanks for your help. I see I will need to make some code in order to have only 1 item in nested rows selected at the same time. I.e: If I check one row in second level, parent and children of this level will have to be unchecked.
    So now, I’m trying to find which parents and / or children are previously selected when an item is checked, in order to uncheck them. I’m having some issues when coding functions to get parents and children of a checked row ($(‘#treeGrid’).on(‘rowCheck’…). Could you help me with an easy function to get this? I don’t know how to process the array returned by var args = event.args; var row = args.row; …
    Thanks again.


    es3
    Participant

    Well, finally I managed two little functions to determine in my 3 level hierarchy, which parent and/or children items are checked to uncheck them, in order to have only 1 level checked at the same time.
    jQWidgets library and also my little functions work properly at starting point, but I’m experiencing some issues when sorting:
    After sorting any column, rowCheck event does not “remember” which parent / children items were checked before sorting (but item(s) checkbox remains “true”).
    Also, even if no items were previously checked, items that are checked after sorting are not stored in row arguments (checked is undefined), so I cannot exclude this hierarchy.
    I.e.: after render, I sort by any column. After that, I check 1 level item in a row. Then, I check its second level item. In “rowCheck” event, I log the whole args object, and I can see that parent.checked of this level 2 row is not defined (should be true as level 1 is also checked).

    Maybe a little bug or perhaps sorting function is not compatible with these kind of process?

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

You must be logged in to reply to this topic.