We have AsODataEnumerable() extension method for IEnumerable which will return ODataEnumerable<T> . If you bind the grid using the extension method you will have OData expression in Filter property, if not Dynamic Linq expression. If you want to get the column filter values you can loop ColumnsCollection property and check FilterValue column property.
I need the filter as an OData filter expression because it is passed to my API (along with various other properties) and then Commuinity.OData.Linq parses it. I'm using the DevExpress grid at the moment and it works fine, but it doesn't have a push approach for paged data. Your grid supports both pull and push (which I require) but I am unable to do the server-side OData filtering.
AsODataEnumerable() is our extension methods that will create ODataEnumerable<T> wrapper over any IEnuemreable<T> and will tell the DataGrid to use OData syntax for filtering, sorting, etc.
I'm not sure if I am not explaining my requirement properly, or if I am not understanding the answer. Let me try rewording.
API contract
public class FindClients
{
public string ODataFilter { get; set; }
public string ODataOrderBy { get; set; }
public int Skip { get; set; }
public int Take { get; set; }
}
Blazor client
private asyc Task SomeEventCalledByYourGridWhenFiltersOrOrderingOrPageNumberChanges(YourGridArgs args)
{
var request = new FindClients
{
ODataFilter = ???,
ODataOrdering = ????,
Skip = (this is available in args),
Take = (this is available in args)
}
var response = HttpClient.PostJsonAsync<FindClientsResponse>(.....etc......, request);
}
When your grid changes filters or ordering, and before I have any data from the server API, how do I get the filter and order in OData syntax to pass to my API? The API is not an OData endpoint, it just expects order and filter to be in OData syntax.
Did you check our demo? Does it work for you as you would expect? As @enchev said you have to set the Data property of the Radzen DataGrid to something which is ODataEnumerable (which you can obtain via the AsODataEnumerable extension method which Radzen provides). Try the demo project and put a breakpoint in the LoadData event handler.
I cannot simply pass an IEnumerable<T> as the data source if I want the filter in OData format. I have to use your AsODataEnumerable() extension and the grid will check if the source is ODataEnumerable<T> and, if so, then return the filter in OData format instead.
I would never have suspected this, and even when you told me about it I still struggled to understand what the approach is.
Having a property called something like UseODataFilters on the grid would be a much better approach I think.