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

I cannot find example of DataManager bind remote data of ej-grid to webapi (ASP.NET)

I cannot find example of DataManager bind remote data of ej-grid to  webapi (ASP.NET)

I try ajax it can bind but on first time not bind (click 2nd time if bind)
I try to use your dataManager by see another example it can not work.

thank for advise

1 Reply

AS Alan Sangeeth S Syncfusion Team October 27, 2014 09:21 AM UTC

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


Loader.
Live Chat Icon For mobile
Up arrow icon