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

[FromBody]DataManagerRequest in action controller

Good morning,
is it possible to use  GET method with DataManagerRequest?
I need to view filter grid in url but I can't at the moment because DataManagerRequest is in POST method action controller.
Is it possible something like the following code?
Public IActionResult Index (DataManagerRequest dm) {}

Or is there another way to use filter with GET method?


3 Replies

PS Pavithra Subramaniyam Syncfusion Team June 3, 2019 06:18 AM UTC

Hi Mini, 

Thanks for contacting Syncfusion support. 

By default, while using UrlAdaptor for remote data, POST request will be sent for fetching the data from server. If you want to send the GET request for data fetching then you can use “WebApiAdaptor” . However you need to handle the Grid actions like filtering, sorting in server side and return the data as Items, Count pair. Please refer to the below documentation for more details. 
Please get back to us if you need any further assistance on this.   
Pavithra S. 

MD Mini Dev June 3, 2019 12:39 PM UTC


how can I handle filter server-side?
I need get filter by query parameter and convert it to a strongly-typed model.
Is there something ready? Or do I have to develop my own code to obtain that?

public IActionResult Test([FromQuery(Name = "$skip")] int skip, [FromQuery(Name = "$top")] int top, [FromQuery(Name = "$filter")] string filter)


filter is "(OrderId eq 477) and (CustomerId eq 135) and (startswith(tolower(CartCode),'235'))"

I need to have a model with the following property:

Has Syncfusion made something of similar? Or do I have to create my custom model and valorized it?

PS Pavithra Subramaniyam Syncfusion Team June 4, 2019 07:22 AM UTC

Hi Mini, 
For WebApiAdaptor you need to handle the filtering and create the model by manually at server end point. We have prepared a simple sample for server side Menu filtering with WebApiAdaptor for example. Please refer to the below code example and sample link for more information.  
  public class OrdersController : Controller  
        // GET: api/Orders  
        public object Get()  
            var queryString = Request.Query;  
            var data = OrdersDetails.GetAllRecords().ToList();  
            string filter = queryString["$filter"];  
            string auto = queryString["$inlineCount"];  
            // filtering  
            if (filter != null)  
                var newfiltersplits = filter;  
                var filtersplits = newfiltersplits.Split('('')'' ');  
                var filterfield = filtersplits[1];  
                var filtervalue = filtersplits[3];  
                if (filtersplits.Length == 5)  
                    if (filtersplits[1] == "tolower")  
                        filterfield = filter.Split('('')''\'')[2];  
                        filtervalue = filter.Split('('')''\'')[4];  
                if (filtersplits.Length != 5)  
                    filterfield = filter.Split('('')''\'')[3];  
                    filtervalue = filter.Split('('')''\'')[5];  
                switch (filterfield)  
                    case "CustomerID":  
                        data = (from cust in data  
                                where cust.CustomerID.ToLower().StartsWith(filtervalue.ToString())  
                                select cust).ToList();  
            // paging  
            int skip = Convert.ToInt32(queryString["$skip"]);  
            int take = Convert.ToInt32(queryString["$top"]);  
            if (auto == null)  
                return new { Items = data };  
                return take != 0 ? new { Items = data.Skip(skip).Take(take).ToList(), Count = data.Count() } : new { Items = data, Count = data.Count() };  
You can get the filter parameters in the queryString of the GET request and modify the above code as per your requirement.  
Pavithra S. 

Live Chat Icon For mobile
Up arrow icon