select all rows in sub-grid when selecting a row on grid
I need some help figuring out the how to programmatically select sub-grid rows if I select the row check box. Here is my code http://plnkr.co/edit/oB6AK7uf2TpIJ1V4yi9y?p=preview Also the selected rows state is not saved when I collapse the row.
I've already done that.
Choosing all of the subGrid elements is quite easy.
The problem with your example is, that the subGrid data is always being taken from the server when the subGrid reopens, so it can't save the status.
Here's an example of selecting subGrid rows if selecting the row check box:
http://plnkr.co/edit/Q7B5GKT51sHjgJGth5pJ?p=preview
Look at the TODO in the subGridRegister function - it's pretty easy to do, but something needs to be left for you to do, right? Hope this helps...
Thanks yccteam. I have tried to use the other approach. http://plnkr.co/edit/DfYtLmZrzOMl411AwBrg?p=preview It still doesn't save the state when collapsed and expanded again.
I could not see any change you did, but please check this one: http://plnkr.co/edit/R0kin0RRTbyq05aRUilT?p=preview
Hi yccteam thanks. But I still don't see the check-box states in subgrid being saved when you collapse and expand. Change I made is the subgrid data, it is not doing http server request when row is expanded to display subgrid. http://plnkr.co/edit/DauNfut8l2GTGdbLBipb?p=preview I am trying to see if I can set it in the rowExpandedStateChanged. I am new to Angular and ui-grid. So, I am still figuring out the flow of data.
Hi @kiransmk, In this example: http://plnkr.co/edit/R0kin0RRTbyq05aRUilT?p=preview
- Expand a row
- Make your selections
- Collapse the row
- Expand the row again
- Note that selection was saved.
- Now select the parent row
- Note that all the rows in the subGrid are selected
- Unselect the parent row
- Note that all the rows in the subGrid are unselected From what I understand, fullfils your requirments from above. The code and logic can be different a little bit according to your scenario, but in this scenario my code did the trick. Let me know if I missed something.
Thanks yccteam. Now I see the state is saved when you check the subgrid rows. This is great. But still when I
- Expand a row and select the row to select all rows in subgrid,
- collapse
- expand,
- note the selection is not saved in the subgrid.
The subgrid ceases to exist when the row is collapsed. This is the behavior of the expandable-row feature. It uses ng-if to show/hide the expanded content.
This means that any state that was saved is lost because the element was lost. State would somehow need to be saved in the application itself, outside of the grid.
Sorry for missing your response @kiransmk. Actually, @c0bra 's answer is the reason why in the example above (http://plnkr.co/edit/R0kin0RRTbyq05aRUilT?p=preview) I save the selection status in the parent row and it remembers the selection also after collapsing and expanding. @kiransmk - please verify it works on your end. It works on my end.
- Expand a row and select the row to select all rows in subgrid,
- collapse
- expand,
- note the selection is saved in the subgrid.
Thanks @c0bra, that makes sense now. @yccteam the complete subgrid selection state is not saved. I will try to dig in deeper in the code and see if I can figure it what I want. I will post it on here when I find a solution.
I couldn't get it to work. But, the grouping seems to work for with some modifications. I have one question in grouping too. If you guys can help it would be great. I am performing aggregate on the selected rows, but aggregate is not updated simultaneously on selection of a row. All I want to display is when user selects a row it should update the number of rows selected in sub-group. Here is my code. http://plnkr.co/edit/a7dc4TwiVT7mXCsuxRx1?p=preview
Effectively what you're doing is updating the data in the array, and the grid doesn't notice that unless you tell it. Because what you're doing is updating the data, then you want the grid to run the rowsProcessors again to aggregate the data, the easiest way to do this is queueGridRefresh().
http://plnkr.co/edit/H1B3rKrMM4RaUH5SPVaF?p=preview
Awesome thanks, this works for me. You can close this issue.
Hi c0bra
Can you help me, in UI Grid,
http://plnkr.co/edit/R0kin0RRTbyq05aRUilT?p=preview, selected rows are not when
- Expand grid, 2 Select rows(parent and child)
- collapse 4.Now Expand, selections are disappearing, state is not maintaining , can you help me ,
Thanks..!!