Home › Forums › Guriddo jqGrid JS › Help › How do I only have only 1 subgrid expanded at any time?
Tagged: subgrid expand row, subgridrowexpanded
Hi,
Can anyone help
Using the Two level hierarchy demo would like to only have one subgrid expanded at any given time.
When clicking on any row, would like the previous expanded subgrid collapsed so there is only one subgrid expanded at any given time.
Thanks.
Hello,
One possible solution is to use subGridBeforeExpand event.
The event raises before expanding the new row.
The code can be something like this – use grid options:
|
1 2 3 4 5 6 7 8 9 10 |
.... subGridBeforeExpand: function(divid, rowid) { // #grid is the id of the grid var expanded = jQuery("td.sgexpanded", "#grid")[0]; if(expanded) { setTimeout(function(){ $(expanded).trigger("click"); }, 100); }, ... |
Kind Regards
Thanks Tony.
Works until clicking on a previous expanded subGrid.
Also added missing “}”
|
1 2 3 4 5 6 7 8 9 10 11 |
... subGridBeforeExpand: function(divid, rowid) { var expanded = jQuery(<blockquote class="d4pbbc-quote"></blockquote>td.sgexpanded<blockquote class="d4pbbc-quote"></blockquote>, <blockquote class="d4pbbc-quote"></blockquote>#jqGrid<blockquote class="d4pbbc-quote"></blockquote>)[0]; if(expanded) { setTimeout(function(){ $(expanded).trigger(<blockquote class="d4pbbc-quote"></blockquote>click<blockquote class="d4pbbc-quote"></blockquote>); }, 100); } }, |
Thanks Tony,
Works until clicking on a previous expanded subGrid parent row.
Also added missing “}”
|
1 2 3 4 5 6 7 8 9 10 11 |
.... subGridBeforeExpand: function(divid, rowid) { // #grid is the id of the grid var expanded = jQuery("td.sgexpanded", "#grid")[0]; if(expanded) { setTimeout(function(){ $(expanded).trigger("click"); }, 100); } }, ... |
When reloadOnExpand is true, your code works, when set to false a previous expanded subGrid does not collapse.
You can replicate the problem by clicking on Row1, Row2, Row 1.
What happends:
Clicking on Row 1 expands as expected.
Clicking on Row 2 collapes Row 1 and expands Row 2 as expected.
Clicking on Row 1 expands Row 1 as expected but does not collapse Row 2.
Hello,
Thanks for the code fix.
Your investigation is true. This event is raised only once when reloadOnExpand is true. I will see how this can be fixed.
You can submit this in BugTracker
Thanks.
Kind Regards
Thank you Tony.
As suggested, added bug Issue #3 “Event is raised only once when reloadOnExpand is true”.
Hello,
I have fixed the bug.
You can download the fixed version from GitHub.
If you have difficulties, please let me know
Kind Regards
Hi Tony,
Working now. THANKS.
Is there a min version of the bug fix on github I can download?
Hello,
The download from github differ from the standard download.
After downloading open the js directory and then open the minified directory where the min file is. It is a good idea in this case to replace the css file too, since this is a development (not official) version.
Kind Regards
Kind Regards
Thank you, found the minified directory as you suggested.
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top