We are using igGrid to display different data sources as grids. Since the grid data source is fetched dependent on the structure of a database table that is user controlled we cannot beforehand know the collection of columns or their data type. Due to this we are auto generating columns when binding the data to the grid.
This works fine so long as the user keeps looking at the same view (the same collection of columns). When changing views however the old views' columns aren't cleared. This means if the user was looking at a view with 10 columns and then switched to a view with 4 columns, the new view will have the first 4 columns from the current view and the following 6 columns from the old view.
When binding data to the grid we are using:
$("#dataGrid").igGrid({ schemaGenerated: generateSchema, columnsgenerated: generateColumns, autoGenerateColumns: true, defaultColumnWidth: "150px", width: "100%", dataSource: data, dataSourceType: "json", responseDataKey: "data", features: gridFeatures });
Is there a way to force refresh on the existing grid data source so that it completely drops the old columns?
----
A related issue is that we are using remote paging, sorting and filtering in our grids since the data source can become quite extensive. We are letting the database handle that part and return a controlled size subset of rows that we bind to the grid. The cost of this is that we need to re-bind data using the same code as shown above, after every paging, filtering or sorting activity. The problem is that after re-binding the data, the filtering and sorting properties seem to be cleared off the grid and we need to programmatically write them to the grid again. Is there a way to avoid doing this?
A simple example would be clicking a column header to sort it which would indeed sort the column as expected by re-binding with a new data source that contains a sorted subset of the grid data. But the graphical indicator that the column is sorted will be cleared when re-binding the grid so the user won't get the graphical feedback of the column being sorted. Same goes for filtering, the filter text field is cleared and so is the filter option.
Is there a way to handle remote paging, sorting and filtering without re-binding the data fully? Can you re-bind only the data partially so that it doesn't clear the filter and sorting properties?
We are using ASP.NET and igniteUI v. 13.1.
Hi Maya,
Thank you for the sample, it helps for the iggrid data rerended. i am trying to use the same option $("#tblHierachical").igGrid("option", "dataSource", myDataSource), The data display only at master layout, but the columnLayouts only load the header information, but the data.
Thanks,
Thomas Chai
Do you have any update on this issue?
I have updated the Infragistics script files to the latest ones we have, 2013.2 and that seems to have solved that problem. I can now successfully run your sample when integrated to our solution and I think I have targeted my main issue.
The original error I had was:Unhandled exception at line 226, column 27387 in http://localhost:55765/igniteUI/js/infragistics.core.js0x800a138f - JavaScript runtime error: Unable to get property 'length' of undefined or null reference
And I can replicate that in your sample by simply modifying your GetGridData method to return a string instead of a DataResult (I've attached a sample with these modifications).
The thing is that due to our dataset being generated by user input at runtime we cannot know what columns will exist or how many. The only thing we have to work with is a C# DataTable (which cannot be serialized "as is" due to circular references) so we are building our own JSON and hence we need to return a string, not an object from the server web method. Can you please look at this and provide a sample where the web method returns a string?
Thank you!
EDIT:
I obviously need to JSON.parse() the response from the server in the client, just as ou would in a normal AJAX call. Where would I add that logic?
Your sample works if used as is but it seems to be some issues with the Infragistics scripts/version we use.
when changing the //
// ]]> script tags:
<script src="http://cdn-na.infragistics.com/jquery/20141/latest/js/infragistics.core.js"></script> <script src="http://cdn-na.infragistics.com/jquery/20141/latest/js/infragistics.lob.js"></script>
To the Infragistics script files we use (another version):
<script type="text/javascript" src="scripts/infragistics.core.js"></script><script type="text/javascript" src="scripts/infragistics.lob.js"></script>
I get an error in your sample version saying:
Unhandled exception at line 194, column 29000 in http://localhost:56226/scripts/infragistics.core.js0x800a138f - JavaScript runtime error: Unable to get property 'childNodes' of undefined or null reference
Changing back to the script files you originally used solves this error. We are using version 13.1.20131.1012.
Hello Elin ,
If you have any remote operations like remote paging you’ll need to also make sure that the recordCountKey is set.
Have you had the chance to test the sample I’ve previously attached ( on May 15)?
It returns the data in a similar format :
“
{"d":{"__type":"DataResult","Items":[{"ID":0,"Name":"Name0"},{"ID":1,"Name":"Name1"},{"ID":2,"Name":"Name2"},{"ID":3,"Name":"Name3"},{"ID":4,"Name":"Name4"}],"TotalRecordsCount":20}}
The response data key is : "d.Items"
And recordCountKey: "d.TotalRecordsCount"
Everything works as expected in that scenario.
Test it on your side and let me know if you’re getting a different result. If the sample is not an accurate demonstration of what you’re aiming to achieve please feel free to modify it so that it reproduces the issue you’re encountering, or attach a sample of your own if you have one.
Please let me know if I can provide any further assistance.
Best Regards,
Maya Kirova
Developer Support Engineer II
Infragistics, Inc.
http://es.infragistics.com/support