Hi Krittikorn
We are sorry for the inconvenience caused.
We have created a sample based on your requirement and the
same can be downloaded from below link.
Sample: http://www.syncfusion.com/downloads/support/directtrac/131200/ASPSample-1139529559.zip
We have used a custom adaptor in the above sample to bind
data from webapi service to Grid and we have already logged issue report “Need
to create adaptor for WebApi” to include
an adaptor for WebApi service in DataManager and it will be included in
upcoming Volume 3, 2014 release.
We also would like to let you know that from WebApi service we
need to return data with its count and so we have used “PageResult” to do the
same. Please refer the following code snippets.
<ej:Grid ID="EmployeesGrid"
runat="server" AllowSorting="true" AllowPaging="true" Load="load">
<DataManager URL="api/Values"></DataManager>
....
</ej:Grid>
<script>
var adaptor = new ej.ODataAdaptor().extend({
processResponse: function (data, ds, query, xhr, request, changes) {
if (request.type != "POST")
return
{ result: data.Items, count: data.Count }
}
});
function load(args) {
args.model.dataSource.adaptor = new adaptor;
}
</script>
public class ValuesController : ApiController
{
public PageResult<Order> Get(ODataQueryOptions opts)
{
var results =
opts.ApplyTo(db.Orders.AsQueryable());
var data =
db.Orders.AsQueryable();
return new PageResult<Order>((IEnumerable<Order>)results,
Request.GetNextPageLink(), data.Count());
}
}
|
Please let us know if you have any queries.
Regards,
Alan Sangeeth S