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

Tips on creating custom REST services as data source for Syncfusion controls (i.e. grid)

Hi all,

Could you please give some advice on using the JS controls bound to custom REST services? The potential services will be hosted within SharePoint, which shouldn't change much. They're  just WCF REST methods returning JSON data written in C#.

What interests me:
  1. What format of data is expected by the JS grid control?
  2. How to parse the query parameters i.e. for paging, sorting, grouping etc. Are there any helper classes for this task or should everything be coded from scratch?
  3. How do the possible components (eg. grouping button) translate to query parameters?
Should you know anything about the mentioned matters or can lead me on some further reading, please respond.

Appreciate,
Tomasz

1 Reply

VA Venkatesh Ayothi Raman Syncfusion Team October 17, 2016 12:11 PM UTC

Hi Tomasz, 

Thank you for contacting Syncfusion support. 

By default, the Grid would play well with REST services. Because we have default data adaptor is OData adaptor and WCF REST services uses also OData adaptor. So, our Syncfusion Grid control works well with WCF API. 
Query #1: “What format of data is expected by the JS grid control?” 
If your using OData version 3 then we can bound the data using ej.DataManager with url without specifying any adaptors. For eg. dataSource: ej.DataManager({ url: "place url here" }); . The grid accepts the both JSON light format and verbose format of the OData V3. 
If you are using OData v4 then we should specify the data adaptor as ej.ODataV4Adaptor as specified below,  
dataSource: ej.DataManager({ url: "place url here" }, adaptor:"ODataV4Adaptor");  
Query #2: “How to parse the query parameters i.e. for paging, sorting, grouping etc. Are there any helper classes for this task or should everything be coded from scratch? 
The Grid`s datamanager will build URL based on all Grid actions like paging, sorting, filtering and grouping. For example the request URL generated from Grid, when performing paging is as follows. 
../Northwnd.svc/Employees/?$inlinecount=allpages&$skip=0&$top=5 
The REST services should have capable of capturing the query params from URL and performing  actions in Server side.  
 
Query #3: “How do the possible components (eg. grouping button) translate to query parameters?” 
 
We have unclear about your requirement. if you have mentioned about Syncfusion Grid grouping button or Grouping Button control in JS.  If Grid grouping button, then it will also handle by source level and modified the URL depends upon clicking the grouping button in Grid or please share the more details about your requirement. 
 
Regards, 
Venkatesh Ayothiraman. 


Loader.
Up arrow icon