Hi,
I am using IgGrid and on click of a certain button i am refreshing the grid data by setting the data source on the grid to a new url which makes an ajax call to get data.
Now my search is taking a lot of time to return the data, meanwhile on click of another button i would like to cancel the data refresh that is taking place.
Is there a method available in IGGrid to do that?
Thanks,
Sushma
Hello Sushma,
You need to make an ajax request and when the response is ready there assign it directly to the dataSource. Do not use dataSourceUrl at all.
And if the request is taking too long and the cancel button is clicked abort the ajax request you made for the data.
I got this working by aborting the ajax request made by the grid. Like this :
myGrid.dataSource._ajaxRequest.abort();
But the problem is it is writing this below error in console:
Uncaught Error: The remote request to fetch data has failed: ( abort ) at t.(anonymous function).(anonymous function)._renderData (https://bwvd-rdscale06.asia.manh.com/SCALE/Scripts/IG/infragistics.lob.js:138:15534) at t.(anonymous function).(anonymous function)._renderData (https://bwvd-rdscale06.asia.manh.com/SCALE/Scripts/jquery/jquery-ui-1.10.4.min.js:6:5029) at i (https://bwvd-rdscale06.asia.manh.com/SCALE/Scripts/jquery/jquery-2.0.3.min.js:4:5488) at Class._errorCallback (https://bwvd-rdscale06.asia.manh.com/SCALE/Scripts/IG/infragistics.core.js:271:2290) at l (https://bwvd-rdscale06.asia.manh.com/SCALE/Scripts/jquery/jquery-2.0.3.min.js:4:24882) at Object.fireWith [as rejectWith] (https://bwvd-rdscale06.asia.manh.com/SCALE/Scripts/jquery/jquery-2.0.3.min.js:4:25702) at k (https://bwvd-rdscale06.asia.manh.com/SCALE/Scripts/jquery/jquery-2.0.3.min.js:6:5373) at Object.abort (https://bwvd-rdscale06.asia.manh.com/SCALE/Scripts/jquery/jquery-2.0.3.min.js:6:3212) at HTMLAnchorElement.stopSearchButtonClicked (https://bwvd-rdscale06.asia.manh.com/SCALE/Scripts/manh/insight/manh.ui.insightSearchPaneActions.js:1871:69) at HTMLDocument.dispatch (https://bwvd-rdscale06.asia.manh.com/SCALE/Scripts/jquery/jquery-2.0.3.min.js:5:10006)
I read in one of the posts that onRequestError can be impemented to avoid this error which is coming from renderData event of the grid.
Any idea how this can be done ?
Please see this link : http://ko.infragistics.com/community/forums/p/110329/520572.aspx#520572
I want to do similar implementation, just need to know how to avoid the error on renderData.
Hello Sushma ,
I belive that Pepe is talking about requestError event. And that it should be cancelled -
$(".selector").igGrid({ requestError: function(evt, ui) { return false; }});
I don't recommend this approach, because it requires using internal functionality. I'm attaching a sample demonstrating creating own ajax request to data and then assign the response data as a dataSource to the grid and the request can be cancelled since you have access to it.
Please let us know if you require further assistance.