We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Server side processing

Thread ID:

Created:

Updated:

Platform:

Replies:

132474 Sep 4,2017 11:59 AM Sep 7,2017 02:12 AM JavaScript 5
loading
Tags: ejGrid
Vasily
Asked On September 4, 2017 11:59 AM

Hi, could you give an example of the server side processing? I have big data set I want to process all actions on the server. Under actions, I mean paging, sorting, and filtering. I created test grid, it's working, but it doesn't send any requests to the server when I click sort or anything else. I don't know how to trigger it. Could you give an example what will send to the server and how I need to prepare the response, something like this https://datatables.net/manual/server-side? Thank you
My test code:
        var dataManager2 = ej.DataManager({
url: "/attribute-set/grid",
crossDomain: true
});
dataManager2.adaptor = new ej.UrlAdaptor();
var query = new ej.Query().take(5);
var dataObj = dataManager2.executeQuery(query); //Request the webservice
dataObj.done(function (e) {
console.log(e.result);
$("#grid2").ejGrid({
dataSource: e.result.results,
allowPaging: true,
allowSorting: true,
allowFiltering: true,
columns: ["ID", "CreatedAt", "DeletedAt", "UpdatedAt", "Name"],
});
});

Saravanan Arunachalam [Syncfusion]
Replied On September 5, 2017 12:40 AM

Hi Vasily, 
Thanks for contacting Syncfusion’s support. 
We have analyzed your provided code and you have set the dataSource of Grid as return data (Json) instead of set the ejDataManager instance which is the cause of the issue. Please refer to the below code example to overcome your reported issue. 
$(function () { 
        var dataManager = ej.DataManager({ url: "/Home/DataSource", adaptor: new ej.UrlAdaptor() }); 
        $("#Grid").ejGrid({ 
            dataSource: dataManager, 
            allowPaging: true, 
            filterSettings: {filterType: "menu"}, 
            allowFiltering: true, 
            allowSorting: true, 
            columns: [ 
                    { field: "OrderID", isPrimaryKey: true, headerText: "Order ID" }, 
                    { field: "EmployeeID", headerText: 'Employee ID' }, 
                    { field: "CustomerID", headerText: 'Customer ID' }, 
                    { field: "Freight", headerText: 'Freight', format: "{0:C}" }, 
                    { field: "ShipCity", headerText: 'Ship City' }, 
                     
            ] 
        }); 
    }); 
 
And also we have created a sample based on your requirement that can be downloaded from the below link. 
And also refer the following knowledge base document to know more about server side data operation. 
Regards, 
Saravanan A.       


Vasily
Replied On September 5, 2017 10:07 AM

Thank you, it's working. It will be good to have info about server response somewhere in the documentation. In my case, it didn't work because I didn't know how to prepare server answer.

Server response should be a JSON which contains two fields:

count - a total of found records
results - an array of your columns data

Is it right?



Saravanan Arunachalam [Syncfusion]
Replied On September 6, 2017 01:54 AM

Hi Vasily, 
Yes, we should return the data from server like object (which contains result and count) while using UrlAdaptor (DataManager instance) as a dataSource of Grid control. 
Regards, 
Saravanan A. 


Vasily
Replied On September 6, 2017 07:59 AM

Ok, thank you


Saravanan Arunachalam [Syncfusion]
Replied On September 7, 2017 02:12 AM

Hi Vasily,  
Thanks for your update.            
We are happy that the provided information helped you. 
Regards, 
Saravanan A. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;