I have a test igHierarchicalGrid of two levels, initially it is populated in the view like this:
@(Html.Infragistics().Grid(Model.AsQueryable())....
The grid is working perfectly. I want to simulate an update to this grid so I make a call to GetNewData() action in the controller and return a Json with new data. In the client I rebind to this new data but nothing change in the grid. Look at the sample I have attached.
How to rebind this new json data to the grid?
Hi Tsanna, I have to reopen this case because I found that Product rows are not updated when calling new data. The products 'Coca cola' and 'Tofu' should be 'Coca cola NEW' and 'Tofu NEW' after updating but they are not in the grid. How to fix it? Thanks
Hi thank you Tsanna, I see that your solution really works. Now I would like to understand some things.
1) In my solution I serve the page with data: .Grid(Model.AsQueryable()), in yours the page is served without data but when it is rendered the grid ask for data: .DataSourceUrl(Url.Action("GetData")) Am I right?
2) There is no diference in data structure between your solution and mine (except namespace and usings), however you don't use CategoryId but Id: .ForeignKey("Id") CategoryId is the real foreign key. Shouldn't it be .ForeignKey("CategoryId")?
3) $("#MyGrid").igGrid('option', 'dataSource', newCategories) is very different from $("#MyGrid").igHierarchicalGrid('dataSourceObject', newCategories). This is not obvious according to the available documentation (maybe I didn't find the right place), I would recommend to update it. Thanks again for your support Tsanna.
Hello Luis,
I've modified your project with the following changes:
- changed the model that was passed to the grid
- as a consequence of the above I defined both columns for parent and child layouts
- added "ResponseDataKey" properties for both parent and child grid
- added a separate action in the controller that returns the whole data and pass it as a parameter to DataSourceUrl in the grid configuration
- removed calling of 'dataBind' method after setting the new datasource, because it seems that it re-binds to the old datasource
Attached you can find the project for your reference.
If you have any questions, please let me know.
Regards,
Tsanna