Remote filter trough Web.Api request

Hello,

I started with Syncfusion Blazor just now, so sorry if my question is trivial. :)

I have a Web API and I would like bind it to DaraGrid in blazor webassembly app with Grouping and Filtering.

I attach my controller code and the grid definition in a zip file.

My problems:

1. My method has a parameter: 

[FromQuery] DataManagerRequest dataManagerRequest

but the model binder cannot parse any request from the client to this object.

2. The response not contains the "Items" property, therefore the grid is empty (when I create a temporaly object with Items and Count property then the response format is ok, but this not contains any extra functions like filter). So my question: why the DataResult object not has an "Items" method, or how will work in this case? How need I set the DataResult object to make the grid working?

3. There are any built-in way for server-side filtering? I need develop all filter types manually on every controller?

Thank you for help!

BR, László


Attachment: sourcecode_e99bfa57.zip

3 Replies

RS Renjith Singh Rajendran Syncfusion Team February 8, 2022 02:57 PM UTC

Hi SZL, 
 
Greetings from Syncfusion support. 
 
We have documented a topic to bind data from a WebApi service to Grid. Kindly refer the below documentation for step by step details on creating webapi service and binding data from the webapi service to Grid. 
 
When using the WebAPI services, you need to handle the data related operation at controller based on the querystring you get using the “Request.Query” from the request in Get method.  
 
 
        [HttpGet] 
        public object Get() 
        { 
            ... 
            var queryString = Request.Query;                  //Based on this request query, handle the data related actions. 
            ... 
       } 
 
 
Please get back to us if you have further queries.  
 
Regards, 
Renjith R 
 



SZ SZL February 10, 2022 09:04 AM UTC

Hi,

Thanks for the documentation (unfortunatelly it not contains the filtering and grouping parts but is very useful!)

I see an example about process the GET request manually, but I think this is a cumbersome solution.

So I change the method to HttpPost and it seems the filter working, but the grouping not now. I will continue to understand this part too...

 [HttpPost]

        [Route("readall")]

        public async Task<Object> ReadAsync([FromBody] DataManagerRequest dataManagerRequest)

        { 

           ....

          

             if (dataManagerRequest.Where?.Count > 0) // perform searching

            {

                GridData = DataOperations.PerformFiltering(GridData, dataManagerRequest.Where, "and");

            }

          ....

          

           return dataManagerRequest.RequiresCounts ? new DataResult() { Result = GridData, Count = count, Aggregates = aggregates } :(object)GridData;

        }


And I need modify the client part like this:

 <SfDataManager Url="api/szallito/readall" Adaptor="Adaptors.UrlAdaptor"></SfDataManager>


Now the data loading to grid, the filter and paging seems working, the grouping not now, but I will continue to work on it.

To avoid unnecessary work :) I would like ask, that this conception is good?


Thank you!



RS Renjith Singh Rajendran Syncfusion Team February 11, 2022 09:31 AM UTC

Hi SZL, 
 
Yes, you can use the UrlAdaptor with POST request to use our inbuilt DataOperation methods and DataManagerRequest. Please get back to us if you need further assistance. 
References :  
 
Regards, 
Renjith R 


Loader.
Up arrow icon