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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

117462 Oct 25,2014 01:19 AM Oct 27,2014 05:21 AM JavaScript 1
loading
Tags: ejDataManager
Krittikorn Deeraksa
Asked On October 25, 2014 01:19 AM

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

Alan Sangeeth S [Syncfusion]
Replied On October 27, 2014 05:21 AM

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


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.

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.

;