This is a migrated thread and some comments may be shown as answers.

Angularjs - Nested Grid not retaining expanded grid's filter

3 Answers 157 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ankita
Top achievements
Rank 1
Ankita asked on 20 Apr 2016, 09:02 PM

How to retain expanded grid's filter after dataitem.set()? 

even after using detailExpand and detailCollapse, for restoring expanded rows, we can not keep sort order as it was.
here is the demo : http://dojo.telerik.com/@Ankita/AYOKA

Steps to reproduce: 

1) Expand Row 1 - Product ID 1 -> that will expand sub grid
2) Sort sub grid -> keep company name desc ( you can see company name 5 on top row)
3) Click on button Update total price. ( function call's dataItem.set() method to update parent Rows' column value)
4) you can see Product ID 1 -> Total Price will change to $11.00, keeping sub grid expanded. but here we are lossing sort order of the sub grid. 1st row should be "Company Name 5" not "Company Name 1"

If we do not use dataItem.set and try to assign value as 
"parentDataItem["TotalPrice"] = 10 +  parentDataItem.TotalPrice", grid wont be updated with new value $11.00

Constrain : we have to use "dataItem.set()" to apply css changes to editable cell. we can not use "dataItem.field = value"
becuase it will introduce some other error.
Can you please help me out here? 

Thanks in advance,
Ankita  

3 Answers, 1 is accepted

Sort by
0
Jiatang
Top achievements
Rank 1
answered on 20 Apr 2016, 09:27 PM

Not only the grid's filter, but also the order of rows and something other things.

Order it tricky, because sometimes the user will add new rows on top the grid's. They are not in any sorting order. But we still want to retain that order, keep the new added rows on top.

 

Basically, we don't want to refresh the nested grid when we .set the dataItem of the parent grid.

But if refreshing is inevitable, then at least I want to restore the filter and order.

0
Jiatang
Top achievements
Rank 1
answered on 20 Apr 2016, 09:34 PM
Not only the grid's filter, but also the order of rows and some other things.
Order is tricky, because sometimes the user will add new rows on top the grid. They are not in any sorting order. But we still want to retain it, keep the new added rows on top.

Basically, we don't want to refresh the nested grid when we call the .set on dataItem of the parent grid.
But if refreshing is inevitable, at least we want to restore the order as much as posible.
0
Boyan Dimitrov
Telerik team
answered on 22 Apr 2016, 12:27 PM

Hello Jiatang,

I already replied in the support thread you have opened regarding same problem. Since this might be helpful for someone else I will summarize the information provided in the support thread and post it here. 

The dataItem.set() method will rebind/repaint the Kendo UI grid in order to apply the changes to the UI. This is the reason why all expanded rows are collapsed and needs to be expanded again. Expanding the parent row initializes the Kendo UI detail gird with its configuration options. It does not know anything about its previous state (whether there was a sorting, filtering expression applied).  Same thing applies for the newly create rows, which are not synced with the server. In order to be displayed after expanding the row they should be stored and then set manually (configuration options and new data items).

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Ankita
Top achievements
Rank 1
Answers by
Jiatang
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or