jQWidgets Forums

jQuery UI Widgets Forums TreeGrid jqxTreeGrid rowSelect: grabbing row is different whether the base or a child

This topic contains 3 replies, has 2 voices, and was last updated by  dacracot 5 years, 3 months ago.

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

  • dacracot
    Participant

    I’m having an issue getting the row object from jqxTreeGrid using the rowSelect event. It seems the operation is variable whether the row in the tree is at the base or a child.

    This works for the base but not for children…

    $('#my-grid').on('rowSelect',  function(event){
        var row = event.args.row;
        MSGBUS.bus("myRowSelected").publish(row);
        });

    This works for a child but not the base…

    $('#my-grid').on('rowSelect',  function(event){
        var row = $("#my-grid").jqxTreeGrid('getRow', event.args.key);
        MSGBUS.bus("myRowSelected").publish(row);
        });

    Since there is nothing within jqxTreeGrid that indicates the position within the tree, I can’t quickly switch between base or child, and even so, that would feel like a hack.

    What is a singular way that I can get either base or child row content from a jqxTreeGrid?


    admin
    Keymaster

    Hi dacracot,

    Please, refer to: http://jsfiddle.net/jqwidgets/Y5h6y/. The ‘rowselect’ in the sample is handled and it gets the row’s content. It works for root nodes and also for sub nodes.

    regards,
    Peter


    dacracot
    Participant

    I’m not sure what I was doing wrong, but working through your example helped me to debug my code so that event.args.row is working throughout.

    Thank you.


    dacracot
    Participant

    I think I’ve found the issue. My “dataFields” definition was lacking the specification for several columns. This event.args.row for the base of the parent/child hierarchy reflected this by not containing the missing columns as would be expected. However, the branches of the parent/child hierarchy read and included all the JSON regardless of my “dataFields” definition, and therefore those event.args.row did include the missing columns. As I clicked around the grid, most rows were children and provided the column as I expected, but the root would not, hence my confusion.

    So, my bug was to forget to include all the columns that I needed in the “dataFields”, however I believe the subsequent child rows should also use the “dataFields” and reflect the error rather than reading everything regardless.

    Thanks again for helping me move forward.

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

You must be logged in to reply to this topic.