Radzen DataGrid en OData API filter questions

Hi!

I have been puzzling to get the RadzenDataGrid to work in virtualized mode with a remote odata provider. I managed to with the help of a class from this forum to convert the Filters list to a odata filter string (with some work arounds).

My attempt is located here (a blazor server project with an odata API and a WASM client)

[marinusklaassen/BlazorRadzenDataGridTests (github.com)]

I have some questions about the way to deal with the filters:

  1. Looking at the Radzen odata example it should be possible to just the args.Filter string. However in arg.Filter property has to following filter string, which results in an error:
    (Name == null ? "" : Name).ToLower().Contains("10".ToLower())
    I would expect the following filter string:
    Contains(ToLower(Name), ToLower('10'))

I am missing some step here?

  1. Somebody on this forum built the FilterDescriptorExtensions GetColumnODataFilter. However it does not seem to play well with column where the data type is a boolean or number.

This part here always returns a type of string: var filterPropertyType = column.Property.GetType();

Which gets me to the following: How can I determine the data of the property where the column is bound to?

For now as a quick workaround I did the following:
if (property == "IsVerified") // Quick fix.
{
return $"{property} eq {value.ToLower()}";
}

With kind regards,

Marinus

Hi @Marinus,

You can use our OData demo as a basis. Check the Northwind service which does the URL handling.

var uri = new Uri(baseUri, $"Categories");
uri = uri.GetODataUri(filter:filter, top:top, skip:skip, orderby:orderby, expand:expand, select:select, count:count);

GetODataUri is an extension method which will convert a string filter from the LoadData event args to OData format.

Make sure to use AsODataEnumerable() when assigning the data of the datagrid:

async Task LoadData(LoadDataArgs args)
{
    var result = await service.GetEmployees(filter: args.Filter, top: args.Top, skip: args.Skip, orderby: args.OrderBy, count: true);
    employees = result.Value.AsODataEnumerable();
    count = result.Count;
}

Thanks!

The problem was that I initialized the GridItems using a List. That bites with the GridItems = result.Value.AsODataEnumerable() assignment.

I managed to get the GetColumnODataFilter filters based on type selection working by fetching the property type like this:
var filterPropertyType = typeof(T).GetProperty(property).PropertyType;

With kind regards,