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
close icon

Grid Support in ASP NET Core

Hi,
I am having many difficulties using the ejGrid in a ASP NET COre project in which I want to use the Remote data access (Load and save data)
I cannot use the OData Adaptor, because the OData support in ASP NET Core is not implemented (or I don't know how to use it).
I am trying the Web API Adaptor, but I am not able to retrieve any data, even if the web api is called correctly.
The grid gives me an error reponding to Action Failure that says "200: OK", which seems the status code for a correct call.
Could you give me a working sample using the last version of librarythat helps me with this issue?

     Thanks in advance

    Andrea Perazzolo

2 Replies

AP Andrea Perazzolo July 29, 2016 12:23 PM UTC

I forgot to say that I am using the Essential Javascript grid control inside an ASP NET CORE project.


SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team August 1, 2016 01:42 PM UTC

Hi Andrea, 

We have prepared a sample with the ejGrid and WebApiAdaptor in the ASP.Net core project that can be downloaded from the following location. 
                           

To handle the webapi service in the Grid, you have to use the ej.WebApiAdaptor via ej.DataManager and the server must return the object wrapped with the result and count pair as shown in the following code example. 

    <div id="Grid"></div> 
    <script type="text/javascript"> 
        $(function () { 
            $("#Grid").ejGrid({ 
                dataSource: ej.DataManager({ 
                    url: "/api/Orders", 
                    adaptor: new ej.WebApiAdaptor() 
                }), 
                allowPaging: true, 
                . . . . 
            }); 
        }); 
    </script> 
 
        // GET: api/values 
        [HttpGet] 
        public object Get() 
        { 
            BindDataSource(); 
 
            var queryStrings = Request.Query; 
            var qsList = new List<string>(); 
            foreach (var key in queryStrings.Keys) 
            { 
                qsList.Add(queryStrings[key]); 
            } 
            var queryString = HttpContext.Request.QueryString; 
            var dataSource = order; 
            var data = dataSource.Skip(Convert.ToInt32(qsList[2])).Take(Convert.ToInt32(qsList[3])).ToList(); 
            return new { result = data, count = dataSource.Count() }; 
        } 


The sample is prepared ASP.Net Core Preview-2 final project. So we ask you to update the Essential Studio to 14.2.0.28 which supports the preview2 final update of ASP.Net core. Essential Studio 2016 Volume 2 Service pack Release v14.2.0.28 is rolled out and is available for download under the following link: 
                            

Refer to the following Help Document. 


Regards, 
Seeni Sakthi Kumar S. 


Loader.
Live Chat Icon For mobile
Up arrow icon