jQWidgets Forums
jQuery UI Widgets › Forums › TreeGrid › jqxTreeGrid rowSelect: grabbing row is different whether the base or a child
Tagged: rowSelect getRow TreeGrid
This topic contains 3 replies, has 2 voices, and was last updated by dacracot 5 years, 3 months ago.
-
Author
-
March 18, 2020 at 4:27 pm jqxTreeGrid rowSelect: grabbing row is different whether the base or a child #111450
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?
March 21, 2020 at 12:36 pm jqxTreeGrid rowSelect: grabbing row is different whether the base or a child #111473Hi 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,
PeterMarch 23, 2020 at 3:26 pm jqxTreeGrid rowSelect: grabbing row is different whether the base or a child #111500I’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.
March 23, 2020 at 6:49 pm jqxTreeGrid rowSelect: grabbing row is different whether the base or a child #111512I 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.
-
AuthorPosts
You must be logged in to reply to this topic.