Unplanned
Last Updated: 15 Nov 2022 08:04 by ADMIN
Rayko
Created on: 15 Dec 2020 13:08
Category: Grid
Type: Bug Report
7
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

11 comments
ADMIN
Radko
Posted on: 15 Nov 2022 08:04

Hello Stefan,

The best way to keep in track with the progress of this item is to follow it - this way you will receive updates as soon as its status changes. Besides this, one could cast their vote to raise the item's popularity, but I see you have already done this.

In the meantime, I have provided a plausible workaround in a previous reply - have you tried using it while waiting for a fix?

Regards, Radko Stanev 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/.

Stefan
Posted on: 08 Nov 2022 14:48

any news related with this?

we also need this functionality..

ADMIN
Radko
Posted on: 17 Oct 2022 11:06

Hello Meindert,

A possible workaround for this is to take control of the creation of the FilterDescriptor objects associated with the problematic nullable fields of the ExpandoObject. This could be achieved through a FilterMenu template (refer to FilterRow template if this is what you are using) for the given column. Through this template, you can set the appropriate descriptor's MemberType property to correctly reflect the field you are filtering on. I have attached an example that demonstrates my idea. Note this is a rather basic example, and filter value setting/resetting is not properly implemented.

Note this would require defining your own filter template, including setting available operators and so on, but hopefully should suffice as a workaround until a fix is provided.

Regards, Radko Stanev 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/.

Attached Files:
Meindert
Posted on: 10 Oct 2022 12:57

Hi,

We have to deliver the website within 3 months after one and a half year of hard work. It looks and works very well. The only thing is that we have still serious problems to get rid of a couple of issues related to filtering on columns with null values in the expando objects. We need those objects because we have a dynamic grid engine that generates pages on the fly. The fact we have null values is described below.

Creating an issue results in useless answers like, make a static object, or prevent null values or make columns strings and etc.

Please provide us with a working Grid/ExpandoObject combination or provide us with an working work around based on ore needs !!

 

Kind regards, Meindert

ADMIN
Radko
Posted on: 17 May 2022 08:28

Hi Meindert,

Thank you for the clarification. Indeed, I was able to reproduce the described behavior following the steps you have provided. After having a look, I can confirm this to be the same issue as discussed in this thread already, which stems from the way the DataSource package works with Expandos and nullable types.

I can see you have already voted for its fix and as you are following the thread, you will automatically receive notifications about its progress.

Regards, Radko Stanev Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Meindert
Posted on: 11 May 2022 05:32

Hi Radko,

The data we have to deal with is both "null" and "0" meaning full. Measurement with 0 as result or no measurement done.

The grid itself seems to handle this well on type="decimal". Also the Aggregate.Max shows a value. It seems not logic to use decimal and not decimal? but with expandoobject it works.

Problems are with:
- Filtering on Salary hangs the page;
- Aggregate.Average prevents starting the page, nothing shown.

In your described example you could reproduce this by adding some null values.

decimal salary = (decimal)rand.Next(1000, 5000);
ExpandoObject employee = new ExpandoObject();
employee.TryAdd("Salary", (i > 2 ? salary : null));

After using column type decimal? the Aggregate.Average works fine.

The filtering is still a problem.

Kind regards, Meindert

ADMIN
Radko
Posted on: 10 May 2022 13:55

Hi Meindert,

If I understand correctly, you had to introduce nullable types in order to get the aggregates to work correctly? 

The above-described issue stems from the nullable types themselves and if there is no need for such, the Grid should pick up the correct FilterOperator by itself. We have an example (https://github.com/telerik/blazor-ui/tree/master/grid/binding-to-expando-object) that demonstrates binding to Expando, grouping with aggregates that might be helpful.

If I misunderstood, could you please elaborate more in regards to why nullable types were needed for the aggregates to work?

Regards, Radko Stanev 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/.

Meindert
Posted on: 04 May 2022 05:16

Hi,

We use in our project expando objects and have column types decimal, int, datetime and string. There was no major problem without defined nullable types. 

For aggregation we use decimal? and int? because it seems not to work without it.

Problem now is to get the correct filter ?!

Are there some hints for using expandoobject, aggregation and filtering ?

 

Regards, Meindert

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/.