The result of above code example is illustrated as follows.
URL Adaptor
URL Adaptor of DataManager can be used when you are required to use remote service to retrieve data. It interacts with server-side for all DataManager Queries and CRUD operations.
UrlAdaptor has the following unique in-built methods,
Properties
Parameters
Description
processQuery(dataObj, query, hierarchyFilters)
dataObj
Object
ej.DataManager object
query
ej.Query
Sets the default query for the data source
hierarchyFilters
ej.Query
The hierarchical query can be provided by using the hierarchical function.
publicclassHomeController:Controller{publicJsonResultData(DataManagerdataObj){List<Object>data=newList<object>();for(inti=1;i<=10;i++){data.Add(new{OrderID=10240+i,CustomerID="Customer"+i,EmployeeID=i});}varrecords=data.Take(dataObj.Take);// take query of Data ManagerreturnJson(records,JsonRequestBehavior.AllowGet);}}
The result of the above code example is illustrated as follows.
OData Adaptor
OData Adaptor that is extended from UrlAdaptor, is used for consuming data through OData Service. You can use the following code example to use OData adaptor.
ODataAdaptor has the following unique in-built methods,
Result of the above code example is illustrated as follows.
RemoteSave Adaptor
RemoteSaveAdaptor, extended from JsonAdaptor of DataManager, is used for binding local data and performs all DataManager queries in client-side. It interacts with server-side only for CRUD operations to pass the modified records.
JSONAdaptor has the following unique in-built methods,
Result of the above code example is illustrated as follows.
Custom Adaptor
Custom adaptor is a key technique to customize adaptors in DataManager. It is useful to write own adaptor. Normally ej.Adaptor is base class for all adaptors. Therefore you first inherit ej.Adaptor to develop customized one and then you override functionality in custom adaptor with base class.
The following code example illustrates you on how to create custom adaptor.
<divclass="datatable"><tableid="table1"class="table table-striped table-bordered"style="width:700px"><thead><tr><th>FirstName</th><th>LastName</th><th>Email</th></tr></thead><tbody></tbody></table></div><scripttype="text/javascript">$(function(){// Document is ready.//new custom adaptor implementation//able to implement more option in custom adaptor other than insertvarcustomAdaptor=newej.Adaptor().extend({insert:function(dataObj,data){returndataObj.dataSource.json.push(data);},processQuery:ej.JsonAdaptor.prototype.processQuery// reused process query from json adaptor});window.gridData=[{FirstName:"John",LastName:"Beckett",Email:"john@syncfusion.com"},{FirstName:"Ben",LastName:"Beckett",Email:"ben@syncfusion.com"},{FirstName:"Andrew",LastName:"Beckett",Email:"andrew@syncfusion.com"}];vardataManager=newej.DataManager(window.gridData);// assigning custom adaptor to datamanagerdataManager.adaptor=newcustomAdaptor();// insert from custom adaptor usagedataManager.insert({FirstName:"Joel",LastName:"Beckett",Email:"joel@syncfusion.com"});$("#table1 tbody").html($("#tableTemplate").render(dataManager.executeLocal(newej.Query())));});</script><scriptid="tableTemplate"type="text/x-jsrender"><tr><td>{{>FirstName}}</td><td>{{>LastName}}</td><td>{{>Email}}</td></tr></script>
Result of above code example is as follows.
Using Custom Adaptor, you can override the existing method of Extended Adaptor,
Properties
Description
beforeSend
Custom headers can be set using pre-request callback beforeSend, by using the setRequestHeader method can be used to modify the XMLHTTPRequest
processQuery
Used to prepare query string for the request data
processResponse
Used to precess the response which is return from the Data Source
insert
The insert method of the data manager is used to add a new record to the table
remove
The remove action submits the data items that should be deleted
update
The update method is used to update the modified changes made to a record in the data source of the DataManager.
Cache Adaptor
Cache Adaptor is used to cache the data of the visited pages. It prevents new requests for the previously visited pages. It can be enabled by using the enableCaching property. You can configure cache page size and duration of caching by using cachingPageSize and timeTillExpiration properties of the ej.DataManager.
CacheAdaptor has the following unique in-built methods,
Properties
Parameters
Description
processQuery(dataObj, query, hierarchyFilters)
dataObj
Object
ej.DataManager object
query
ej.Query
Sets the default query for the data source
hierarchyFilters
ej.Query
The hierarchical query can be provided by using the hierarchical function.
Cache Adaptor has the following unique properties,
Properties
Description
TimeTillExpiration
Specifies the duration of cached pages in milliseconds
CachingPageSize
A number of pages to be cached
Help us improve this page
Please provide additional information
Please provide additional information
Please provide additional information
Please provide additional information
Please provide additional information
Please provide additional information
×
PHP
The Syncfusion PHP components of Essential JS 1 controls (jQuery-based widgets) are no longer actively developed, and 2022 Volume 4 marks the last release of the Syncfusion PHP components.