jQuery UI Widgets › Forums › TreeGrid › jqxTreeGrid does not expand/collapse row on both: row and button click
This topic contains 4 replies, has 2 voices, and was last updated by kapalkat 5 years, 9 months ago.
-
Author
-
May 6, 2019 at 9:42 am jqxTreeGrid does not expand/collapse row on both: row and button click #105050
Hey Team
I am implementing jqxTreeGrid in our project. The requirement I have received regarding jqxTreeGrid is to have the ability to expand/collapse a row which contains records whenever I click the button OR the row itself.
Right of the start expanding collapsing with the button works. I was trying to implement this on row click. I used following code:$("#treegrid").on('rowClick', function(e) { if (e.args.row.parent === null && !e.args.row.hasOwnProperty('expanded')) { $("#treegrid").jqxTreeGrid('expandRow', e.args.row.uid); } else if (e.args.row.parent === null && e.args.row.expanded === true) { $("#treegrid").jqxTreeGrid('collapseRow', e.args.row.uid); } else if (e.args.row.parent === null && e.args.row.expanded === false) { $("#treegrid").jqxTreeGrid('expandRow', e.args.row.uid); } });
Seems it did the trick for the row click but right now I have lost the ability to expand/collapse using the button:
Is there any way to make it working properly according to my requirements?
BR
TomekMay 6, 2019 at 9:56 am jqxTreeGrid does not expand/collapse row on both: row and button click #105052May 6, 2019 at 2:59 pm jqxTreeGrid does not expand/collapse row on both: row and button click #105054@jqwidgets based on your jsfiddle collapseRow example I have created new one which shows the problem:
http://jsfiddle.net/kapalkat/53cs9j8q/5/May 7, 2019 at 10:45 am jqxTreeGrid does not expand/collapse row on both: row and button click #105071Hello Tomek,
It was a workaround because there is no built-in option.
I would like to suggest you look at this example.
I hope the above is useful to you.Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.comMay 7, 2019 at 2:37 pm jqxTreeGrid does not expand/collapse row on both: row and button click #105079Yes the workaround works fine. Thanks!
In the meantime I have already created my own workaround which was using event delegation. Attaching it in case someone would like to take a look on it as well.$('#contenttabletreegrid').click(function(event) { var rowIndicator = $(event.target).parents('tr').attr('data-key'); if (rowIndicator) { var row = $("#treegrid").jqxTreeGrid('getRow', rowIndicator); var isRowExpanded = row.expanded; // Fire expand/collapse event if (isRowExpanded === true) { $("#treegrid").jqxTreeGrid('collapseRow', row.uid); } else { $("#treegrid").jqxTreeGrid('expandRow', row.uid); } } });
BR
Tomasz -
AuthorPosts
You must be logged in to reply to this topic.