问题
I am using Infragistics(Ignite UI) controls in my ASP.NET MVC3 application. I have grid which I've bound to 'Customer' data. Works fine. Now I have button. On clicking I make an ajax call. In the controller I write query which selects only a part of 'Customer' data. I return the data using json. I try to re-bind it using:
$("#CustomerGrid").igGrid("dataSourceObject", returnData);
But the grid continues to show old data. It doesn't refresh.
回答1:
Call the data bind method like so:
$("#CustomerGrid").igGrid("dataSourceObject", returnData);
$("#CustomerGrid").igGrid("dataBind");
or even like so:
$("#CustomerGrid").igGrid("dataSourceObject", returnData).igGrid("dataBind");
Just a general note - changing the data source can be extra overhead and generally not ideal solution. If I understand correctly you are replacing it with a part of the original collection? If the collection is big and/or you need to reset back to original state - perhaps consider simply returning id-s to the ajax call and use the Filtering feature?
来源:https://stackoverflow.com/questions/15765246/how-to-re-bind-the-data-in-the-iggrid-igniteui-control-on-click-of-a-button