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

Filter, Sort & pagin on server side without Odata ?

Hi,

I am actually evaluating the possibility to use the syncfusion controls in a futur asp.net core projet, however i have an unanswered question.

In my scenario, i would like to have the server side as Asp.Net Core and the client side with several client side, including asp.net core (web api/mcv website), WPF client and mobile apps (native or xamarin).
Therefore, i would like to have a the same data access for all of them, and Asp.Net Core Web Api seems just fine to reuse the same code for any possible client.
The fact is that OData for .Net Core web Api is far from being ready..

Question: Can we bind the grid (the asp.net core version and the wpf version) to the .Net core web api service, and be able to use CRUD operations and full server side search, filter, sort, paging features just as we would do using odata ?

Loading all the table (even on the server side) to after that perform the filtering is not an option due the my huge tables (something like this sample does is not possible in reallife: https://help.syncfusion.com/aspnet-core/grid/filtering?cs-save-lang=1&cs-lang=csharp).

Not sure that i can succeed with the DataManager.

Thanks for your suggestions.

3 Replies

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team April 12, 2017 10:56 AM UTC

Hi Customer,  
 
Thanks for contacting Syncfusion Support.  
 
We have prepared a sample with a WebApi Service call that can be downloaded from the following location.  
 
 
The DataManager provides various adaptors to handle different remote service. Refer to the following Help Document. 
 
 
Among this, we will use the WebAPIAdaptor to bind the dataSource to the Grid from the WebAPI service call. Refer to the following code example and Help Document. 
 
 
        [HttpGet] 
        public object Get() 
        { 
            var dataSource = _context.Orders.Take(100).ToList(); 
            var queryString = Request.Query; 
 
            int skip = Convert.ToInt32(queryString["$skip"]); 
            int take = Convert.ToInt32(queryString["$top"]); 
            string sort = queryString["$orderby"];//sorting    
            string filter = queryString["$filter"]; 
            if (sort != null) { 
                dataSource = dataSource.AsQueryable().OrderBy(sort).ToList(); 
            } 
                         . . . 
                             . . . 
            var count = dataSource.Count; 
            return new { Items = dataSource.Skip(skip).Take(take), Count = dataSource.Count() }; 
        } 
 
 
<ej-grid id="Grid" allow-paging="true" allow-sorting="true" allow-filtering="true"> 
    <e-datamanager url="/api/Orders" adaptor="WebApiAdaptor"></e-datamanager> 
    <e-columns> 
        <e-column field="OrderID" header-text="Order ID" is-primary-key="true" text-align="Right" width="75"></e-column> 
        <e-column field="CustomerID" header-text="Customer ID" width="80"></e-column> 
        <e-column field="EmployeeID" header-text="Employee ID" text-align="Left" width="75"></e-column> 
    </e-columns> 
</ej-grid> 
 
 
Also refer to the following API Reference for the Grid’s Sorting/Filtering. 
 
 
Regards,  
Seeni Sakthi Kumar S. 



JE JeanR April 13, 2017 05:19 PM UTC

Thanks for your great answer, seems doable indeed.

At a first look, it seems that only the filtering part will require some work to convert the odata syntax to an linq query.

I will play around it.



MS Mani Sankar Durai Syncfusion Team April 14, 2017 10:47 AM UTC

Hi JeanR, 
 
Thanks for the update. 
 
When using WebAPI without using OdataQueryOptions it is the possible way to do the filtering process in server side for grid. 
Also we will wait to hear from you. 
Please let us know if you need further assistance. 
 
Regards, 
Manisankar Durai. 


Loader.
Up arrow icon