How to re-bind the data in the igGrid igniteUI control on click of a button?

早过忘川 提交于 2019-12-12 14:15:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!