Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
30
Remote Paging
posted

I'm having trouble setting up remote paging on an igGrid that has it's data source set in the success method of an ajax call.  My grid currently loads but paging is disabled.  From what I understand that is because it believes the data source is local not remote.  I need to be able to pass in the AntiForgeryToken which is why I am setting the data source from the ajax call.  Is there a way to get remote paging working in this example?

var page = 0;
var pageSize = 5;

$("#UserTable").igGrid({
autoGenerateColumns: false,
columns: [
{ headerText: "Name", key: "FullName", dataType: "string" },
{ headerText: "Title", key: "Title", dataType: "string" }
],
features: [
{
name: "Paging",
type: "remote",
pageSize: 5,
recordCountKey: "TotalNumberOfResults"
}
],
responseDataKey: 'Employees',
type: 'remote'
});

$.ajax({
url: '@Url.Action("TestGetData", "Employee")',
data: {
pageSize: pageSize,
page: page
},
dataType: "json",
type: 'GET',
headers: {
'ClientId': window.ClientId,
'RequestVerificationToken': window.AntiForgeryToken
},
success: function (result) {
$("#UserTable").igGrid("dataSourceObject", result).igGrid("dataBind");
}
});

  • 15320
    Offline posted

    Hello Rebecca,

    Yes, you're right. Remote paging as well as other remote features work along with remote data. Setting dataSource through the grid API turns the dataSource into local one. In order to use remote Paging in your case I would suggest you to set the grid data by using dataSourceUrl option directly during grid initialization. In order to beware of CSRF attacks you may decorate the action method that returns your datasource with "ValidateAntiForgery" token attribute. Here is a similar topic for your reference: http://www.devcurry.com/2013/01/what-is-antiforgerytoken-and-why-do-i.html.

    Please let me know for further questions.