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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Document describing request and response formats

Thread ID:

Created:

Updated:

Platform:

Replies:

127003 Oct 20,2016 01:29 PM UTC Oct 24,2016 09:17 AM UTC JavaScript 1
loading
Tags: ejDataManager
dan
Asked On October 20, 2016 01:29 PM UTC

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"
    }
  ]
}

Prince Oliver [Syncfusion]
Replied On 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: "http://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 


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.

Warning Icon 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.Close Icon

;