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. Image for the cookie policy date

Document describing request and response formats

I couldn't find any documentation describing your json formats.

Using the Grid as an example:

1) What is the format of the json object produced by the datamanager including meta data?

2) What is the datamanager expecting for a response object?

Example Response:

{
  "page_number": 5,
  "page_size": 20,
  "total_record_count": 521,
  "records": [
    {
      "id": 1,
      "name": "Widget #1"
    },
    {
      "id": 2,
      "name": "Widget #2"
    },
    {
      "id": 3,
      "name": "Widget #3"
    }
  ]
}

1 Reply

PO Prince Oliver Syncfusion Team October 24, 2016 09:17 AM UTC

Hi Dan,   
  
Thanks for contacting Syncfusion Support.   
  
Query 1. What is the format of the json object produced by the datamanager including meta data?   
  
The Datamanager produces JSON object in the following format.   
       actual:Object    
 Contains all the records as it is from the data source.    
       count:13304     
 Contains total count of records.   
       query:ej.Query    
Contains filtering based on query like page index and page size, no of records to take.   
       request:Object   
Contains all the necessary data before posting a request.    
       result:Array[5]    
 Contains filtered results on the data based on query.   
       xhr:Object   
Contains xhr data.     
  
   
  
Query 2. What is the datamanager expecting for a response object?   
Example Response:   
{   
  "page_number": 5,   
  "page_size": 20,   
  "total_record_count": 521,   
  "records": [   
    {   
      "id": 1,   
      "name": "Widget #1"   
    },   
    {   
      "id": 2,   
      "name": "Widget #2"   
    },   
    {   
      "id": 3,   
      "name": "Widget #3"   
    }   
  ]   
}   
  
To get page number and page size in your response, you need to enable paging property of the datamanager using query. To get Total number of records, you need to enable requiresCount property, Refer to the below code snippet.   
var dataManager = ej.DataManager({ url: "https://mvc.syncfusion.com/Services/Northwnd.svc/" });    
var query = ej.Query() .from("Orders") .select("OrderID""CustomerID"" EmployeeID""Freight""ShipCountry".page(1,5) .requiresCount();   
var execute = dataManager.executeQuery(query) // executing query    
        .done(function (e) { // access the response object });   
  
   
  
Note: Page number and page size can be obtained from ‘query’ in response object.     
                        
 
Please refer to the Playground sample.   
  
Refer to the DataManager documentation for more information.   
  
Regards,   
Prince 


Loader.
Live Chat Icon For mobile
Up arrow icon