use Paging in ejGrid by using POST request

Hello Syncfusion.
Currently, I am trying to make the paging in ejGrid work by using client-server request.
I want to display only 10 rows per each page by requesting to the server.
So far .. this worked
var dataManager = ej.DataManager({
url: "${pageContext.request.contextPath}/beacon/test/sync/getStoreListSync.do"
, adaptor: new ej.UrlAdaptor()
});
dataManager.executeQuery(new ej.Query()).done(function (e) {
$("#Grid").ejGrid({
dataSource: e.result.result,
allowPaging: true,
pageSettings: { enableTemplates: true, template: "#template", showDefaults: false },
create : function (args) {
$("#btn").ejButton({
click : "btnClick"
});
},
columns: [
{ field: "storeName", headerText: '', textAlign: ej.TextAlign.left },
{ field: "storeType", headerText: '', textAlign: ej.TextAlign.left },
{ field: "parGroupName", headerText: '', textAlign: ej.TextAlign.left },
{ field: "storeDesc", headerText: '', textAlign: ej.TextAlign.left },
]
});
});

but it does't seem to make the paging work even though I respond the request with the class
public class DataResult {

public List<object> result;
public int count;
public List<object> getResult() {
return result;
}
public void setResult(List<object> result) {
this.result = result;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
}

The count has no effect what so ever and seems to only rely on the array which is given from the start, and when I try the different method
which is in the document
$("#Grid").ejGrid({
dataSource : ej.DataManager({
url : "../sync/getStoreListSync.do",
updateUrl : "Home/Update",
insertUrl : "Home/Insert",
removeUrl : "Home/Delete",
adaptor : "UrlAdaptor"
}),
allowPaging : true,
editSettings : {
allowEditing : true,
allowAdding : true,
allowDeleting : true
},
columns : [
{ field: "storeName", headerText: '', textAlign: ej.TextAlign.left },
{ field: "storeType", headerText: '', textAlign: ej.TextAlign.left },
{ field: "parGroupName", headerText: '', textAlign: ej.TextAlign.left },
{ field: "storeDesc", headerText: '', textAlign: ej.TextAlign.left },
]
});

The server cannot catch the request from the client.
Are there any solutions to this problem, and what have I missed?
Thank you

1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team February 8, 2016 10:05 AM UTC

Hi Maveri,

Thanks for contacting Syncfusion support.

To perform server-side paging operation, we suggest you to use the PerformSkip and PerformTake methods in the server-side. To get dataManager value, we need to refer the Syncfusion.EJ dll in the sample.

Please find the code example and sample:


public ActionResult DataSource(Syncfusion.JavaScript.DataManager dm)

        {

            IEnumerable Data = OrderRepository.GetAllRecords();

            Syncfusion.JavaScript.DataSources.DataOperations operation = new Syncfusion.JavaScript.DataSources.DataOperations();

            int count = Data.AsQueryable().Count();

            if (dm.Skip != 0)

            {

                Data = operation.PerformSkip(Data, dm.Skip);

            }

            if (dm.Take != 0)

            {

                Data = operation.PerformTake(Data, dm.Take);

            }

            return Json(new { result = Data, count = count }, JsonRequestBehavior.AllowGet);
        }


Sample: http://www.syncfusion.com/downloads/support/forum/121900/ze/Sample1185771106186665

DLL Location: C:\Program Files (x86)\Syncfusion\Essential Studio\13.4.0.53\Assemblies

For more information, please refer to the following knowledge Base documentation,

https://www.syncfusion.com/kb/4300/server-side-api-for-datamanager-operations

Regards,
Prasanna Kumar N.S.V


Loader.
Up arrow icon