Hello React Team,
I just have an issue with the filters of a Kendo React Data Grid. It can happen that more than 100 filter values are sent to the .NET Web API via the URL. This then causes an error on the server. Probably due to the length of the request URL or also due to the nesting depth of the JSON. Can the DataSourceRequest also be sent with the body or is it necessary to implement this via the URL?
The URL has a length of about 5,400 characters with 166 filter values.
Thanks in advance for the support.
2 Answers, 1 is accepted
Hello Kendo Team,
I have already found a solution. Using the extension method toDataSourceRequestString and adding it to the request data of a post, sending to the API also works independently of JSON and cross-string restrictions.
I read the solution in another post titled "DataSourceRequest server-side filtering and sorting question" here in the support forum.
But I still have a question
The filters arrive at the endpoint very deeply nested. With many filters we come to the limits of JSON nesting. Why are the filters nested so deeply?
Filters as they are added to the post request in the frontend
Status of the filters in the endpoint
This nesting is proportional to the amount of the filter. I have not found any indication in our application that we explicitly define it that way. Is this by design or have I missed something else here?
Hi Christian,
Regarding the new issue that you are facing, it seems that you are setting "filters" collection within each filter. Note that each filter within the filters array can be either FilterDescriptor or CompositeFilterDescriptor, but both of them have filters array property. What I can suggest is to inspect the DataState and see if the "filters" array (from the screenshot with 9 items) contain expressions with nested "filters". If this is the case, please share the logic that you have for adding those filter expressions or create a stackblitz example demonstrating the exact issue, so we can inspect and test it locally.
Looking forward to your reply.
Regards,
Konstantin Dikov
Progress Telerik
Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources!
Hello Konstantin,
this is the DataState of the grid, which then also runs against the interface. No more changes are made here, except that the State is created with the method toDataSourceRequestString() a string. This string looks normal and the relations between the filters are resolved correctly.
We use the following version in our Web API
Telerik.UI.for.AspNet.Core Version=2021.2.616
DataState
Here, two filter arrays are on the same layer and are related to each other via an and operator. I find the structure correct and wonder about the nested filter object in the interface.
DataState as String
The structure of the filter object is reflected in the QueryString and is not noticeable in my opinion.
pageSize=25&page=1&filter=((ProjectState~eq~'Launched'~or~ProjectState~eq~'Interim%20Launched')~and~(SPDR~eq~'0097A-0110A-15'~or~SPDR~eq~'0097A-0134A-FN'~or~SPDR~eq~'0097A-0134A-US'~or~SPDR~eq~'0097A-0134A-YO'~or~SPDR~eq~'0097A-0134A-YS'~or~SPDR~eq~'0097A-0142W-TT'~or~SPDR~eq~'0097A-0145A-3H'~or~SPDR~eq~'0097A-0145A-MB'~or~SPDR~eq~'0097A-0145A-PW'~or~SPDR~eq~'0097A-0145A-V2'~or~SPDR~eq~'0097A-FLD2A-B1'))
Thanks for your help
Hi Cristian,
The query string looks correct, so if you are getting the nested filters on server-side, it is possible that the model binding of the query string to the DataSourceRequest might be broken for some reason. Can you please share the code in the controller that handles the DataSourceRequest, so we can see if there is something that could be causing the issue.
Additionally, if you pass only a single filter expression from the client-side, does the nested filter issue still appear?
Looking forward to your reply.
Hello Konstantin,
here is a picture of the end point. When I set a breakpoint on the first service call, so nothing has been done with the request yet, I already have this deeply nested object.
Kendo Grid Endpoint
Have a great weekend and thanks for your support!
TBD
I will still add the info if only one filter is sent.Hi Christian,
Thank you for attaching the screenshot.
From what I can see, the configuration is correct and the DataSourceRequest should work correctly, especially since the query string is also correctly build.
Before we proceed further, could you please share the screenshot with the DataSourceRequest that you are receiving with the multiple levels of nested filters, because the previous screenshot (from 24 October) is blurred and it is almost impossible to read anything. Maybe looking at the structure of the DataSourceRequest might help us determine what is causing the issue.
Looking forward to your reply.