Selecting rows in sub-grids (state is not maintained on expand/collapse)
Hi , Could some one help me with the Expandable UI Grid , ( UI Grid with In UI Grid) , code in plnkr - http://plnkr.co/Eeg5YiIvFa5TpD8PLb3i . I was trying to find out the code , that can be used to capture child grid (sub grid) raw selection , any help on this topic will be welcome.
thanks
Can you explain exactly what you mean by "sub grid raw selection"? It sounds like you're wanting to select rows in sub-grids but I can't be sure.
Yes , i want to allow the user to select a row in the sub grid and need to capture the event in the controller , set the selected raw values to a $scope variable.
thanks
Could you please acknowledge my response , i just wanted to make sure , i have conveyed it correctly.
@tojojose Yea sorry I understand what you're trying to do.
Unfortunately right now it looks like subgrids don't maintain row selection state on expand/collapse so your use case will be a bit broken.
The way you'd want to go about it is to register a gridApi.selection.on event handler for all your subgrid options and push/splice the selected/deselected rows into a single array in your parent scope.
Problem is that it will be broken until the subgrid state issue is fixed. I'll mark this as a bug.
@jpuri do you have any ideas on maintaining state in subgrids like this?
@c0bra currently to maintain selection state we can make use of event "rowExpandedStateChanged" to save the selected rows when subgrid is closed.
But yes we can take up this as enhancement of maintaining subgrid state across expand / collapse.
@tojojose, for details of subgrid scope check "expandableRowScope" in tutorials, let me know if you need more details.
Hi @c0bra , @PaulL1 ,
Any thoughts on how can we implement subgrid state. I think its right now broken because of some issues with how scope works for grid. Subgrid exists in scope of enclosing row.
@jpuri yes I think we'd have to update state-saving a bit and register a different location (i.e. the GridRow object) to store the state in.
There is actually some complexity to it:
- Subgrid can be anything a grid or whatever else user provides in the template.
- When an expandable grid is rendered and expanded subgrid is appended to each row although its hidden. When user choses to expand the row this subgrid is shown. If we show hide a top level grid its state is maintained but this is not the case with subgrid.
- A subgrid is a complete grid in its own and does not have idea of its parent grid. Its state exists independently. Thus a grid never know if its sub-grid and should save some state or reload some state.
If you were OK with a dependency on saveState, you could call saveState on collapse, and save it on the parent row (perhaps as row.subgridState), then call restoreState when you show it again.
Something about this feels a bit wrong to me though - it feels too complex and therefore perhaps too fragile. But maybe you just put in the saveState call and it just works.
Actually subgrid's scope is child of parent grid, I have no access to subgrid in supergrid. Thus its difficult for me to get sub-grid state (subgrid again can be any template not just ui-grid).
What looks more appropriate to that I add callback for user to be able to save and set subgrid state. But it might be difficult for even user to reset sub-grid state as he also will not have direct access to subgrid scope.
But I am sure there would be some way to achieve, let me think more about it.
Hi @jpuri and @c0bra,
Any updates on this enhancement? I am currently dealing with this issue.
Thanks!
Hi Guys,
I am having difficulty with sub-grid. I having sub-grid under main UI-grid and after expanding parent row, I'm selecting rows from sub-grid and then collapsing parent row. After I'm expanding parent raw again, my selected rows goes un-selected. I am using gridApi.expandable.on.rowExpandedStateChanged event. attached is my code for the same.
Kindly advice me soon, as it's kind of urgent. UI-Sub_grid.txt
I have managed to fixed this...
@girish-fuluskar You can reset the link to your source? solution to the problem. thanks)
@girish-fuluskar Could you please share how this has been solved?
Use the timeout function. Implemented, maybe not beautiful, but WORKS.
Then refused to use ui-grid, due to the absence of the third state.
Look, who can help with the developments.
Happened. File attached: MyCtrl.txt
Hi @girish-fuluskar Can you help me, how you managed the subgrid selection, after collapse. I need it on priority . My code is similar kind of thing. http://plnkr.co/edit/R0kin0RRTbyq05aRUilT?p=preview
thanks.!!