Completed
Last Updated: 22 Apr 2024 07:47 by ADMIN
Release 2024 Q2 (May)
Rayko
Created on: 15 Dec 2020 13:08
Category: Grid
Type: Bug Report
14
Incorrect filter operators when the FieldType is set to a nullable numeric data type.

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

15 comments
ADMIN
Radko
Posted on: 10 Jan 2024 13:56

Hi Peter,

I apologize for the inconvenience. We prioritize items based on multiple factors, one of which is its popularity. Given the amount of attention this item has attracted, it is very likely we will include it in our planning. Lastly, the best way to get notified for its status is to follow this thread.

Regards,
Radko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Peter
Posted on: 04 Jan 2024 07:33
3+ years..  Doesn't seem that Telerik is very committed to actually fixing their bugs if you ask me.
ADMIN
Radko
Posted on: 03 May 2023 11:49

Hi Alexander,

In order to explain why the Is null and Is not null operators appear, I should include a few details of the current implementation.

One specific is that the current implementation always includes the IsNull and IsNotNull operators, despite whether the the bound type is nullable or not. We have a public bug report about this, which once resolved, will omit the above-mentioned operators if the bound type is non-nullable. Here is a link to the item, where you can cast your vote if you see value in it: https://feedback.telerik.com/blazor/1481544-non-nullable-numbers-still-get-the-isnull-and-isnotnull-filter-operators

Another specific is that the internals currently rely on resolving filter operators for non-nullable types only. As for how the type is determined - whenever a filter is requested, the column decides what operators to use based on either the underlying type of the Field parameter(if such is provided), or the FieldType parameter, which is taken as-is. Due to this specific, operators are properly populated for nullable fields in non dynamic configs(which is when the Field parameter is used mostly anyway), but are not for nullable types passed to FieldType(which is often used when the Grid is bound to dynamic objects). Because of this, when using FieldType, correct filters are resolved only when the passed type is non nullable - in all other situations, a set of default operators are used, which are the standard ones for the type string, thus not applicable for a numeric value.

As for a potential workaround - would it be possible to use non-nullable types and instead define a cell template, similar to what Kristian has suggested earlier in this thread? The template will allow to correctly format the value within the cells(e.g. do not show anything if value is null), but should set the correct operators, due to the specific I outlined above. If this is not an option, would you be willing to share more details for your exact use-case, so I can better understand the scenario? Thank you.

Regards,
Radko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Alexander
Posted on: 26 Apr 2023 17:44

We are also looking for this.

I really don't understand this.

Clearly the intention was for there to be null support since there are filters in the drop-down for it!?  And that is on a column that isn't even supposed to be nullable...

Is there at least some way to inherit from the existing templates so we don't have to completely re-implement the filtering for each type?  Or can you provide us with the original templates so we can modify them?

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