Unplanned
Last Updated: 29 Dec 2020 15:27 by ADMIN
Rayko
Created on: 15 Dec 2020 13:08
Category: Grid
Type: Bug Report
2
Correct filter for ExpandoObjects with nullable types

Hi Telerik team,

 

When I want to bind the Blazor Grid to an ExpandoObject I need to assign the FieldType. I know I have to use non-nullable types.

But I want to use nullable types (for example int?) to have a blank cell within the Grid when there is no value for it. With "typeof(int)" instead of "typeof(int?)" every empty cell shows "0" which I don't want.

Is there any chance to let FieldType accept nullable types?

 

Best regards,

Rayko

3 comments
ADMIN
Kristian
Posted on: 29 Dec 2020 15:27

Hello Rayko,

Thank you for the additional information you provide.

I dug more into the case and you are absolutely right - It's a filter issue and the main limitation comes from the way our DataSouce abstraction operates with expando object properties.

I also found that it's possible to extend the current implementation to support nullable value types, so I'm changing the status of the Feature Request to Unplanned and you can Follow its progress on this page.

Regards,
Kristian
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Rayko
Posted on: 21 Dec 2020 16:23

Hi Kristian,

Thank you for your reply!

I already use column templates to populate nullable expandos. But the built-in filter isn't able to handle these. Every column is treated as a string column. Even numeric columns have a "Contains" filter operator available. So every attempt to filter ends up with: Error: System.ArgumentException: Operator 'Contains' is incompatible with operand types 'Int32?' and 'String'

So, it's more or less a filter issue.

And yes, I've already built custom filters to work around this issue. But custom filters cannot be persisted using Json (as I described in another thread).

 

Best regards,

Rayko

ADMIN
Kristian
Posted on: 21 Dec 2020 15:49

Hi Rayko,

Thank you for this feature request.

You are right that it will be really useful if binding the Grid to ExpandoObject could handle nullable types automatically.

We need to investigate deeper if this is doable with the current implementation, though. 

I will gather more information and I will follow up to you and to share the results of the investigation.

 

Until then, I can offer you an easy workaround to show the null values in the columns:

Define templates of your columns that showing the value directly from the current expando object. Here is some sample code:

 

<GridColumn Field="Age" FieldType="@typeof(int?)">
    <Template>
        @(((IDictionary<string, object>)context)["Age"])
    </Template>
</GridColumn>

 

 

Regards,
Kristian
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.