Grid number filter precision

1 Answer 56 Views
Filter  Grid
Jie
Top achievements
Rank 3
Iron
Iron
Iron
Jie asked on 30 Aug 2024, 08:57 PM | edited on 30 Aug 2024, 09:12 PM

Hi,

 

If a Grid column is using number filter, its precision can only be 0.001. Is there a way to increase that?

See this Kendo React official example, the "Unit Price" filter can only take 0.001, not able to take 0.0001.

https://www.telerik.com/kendo-react-ui/components/grid/filtering/

 

I tried changing the column format to "{0:n6}", but it only affect the grid cell, not the filter.

 

Thanks,

Jie

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Yanko
Telerik team
answered on 02 Sep 2024, 02:17 PM

Hello, Jie,

Yes, you can increase the precision of the filter. You can achieve that by utilizing the `filterCell` property of the Grid Column. This allows you to use a custom input field inside the filter to set its format:

      <NumericTextBox
          format="n6"
          width="110px"
          onChange={onChange}
          value={props.value}
        />

You can read more about custom filter cells in this article from our documentation:

I have prepared an example for you that displays the mentioned approach:

Please let me know if I can provide further help on the matter.

Regards,
Yanko
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.

Jie
Top achievements
Rank 3
Iron
Iron
Iron
commented on 04 Sep 2024, 02:35 PM

Hi Yanko,

The problem is that I want to use column header menu too, like in the official document - https://www.telerik.com/kendo-react-ui/components/grid/interactivity/column-menu/.

The filterCell prop doesn't seem to work anymore with header menu. The filter is only determined by filter prop, i.e, 

filter={"numeric"}


Thanks,

Jie

Yanko
Telerik team
commented on 05 Sep 2024, 03:14 PM

Hello, Jie,

You can make changes to the header menu of a column with the `columnMenu` property. It allows adding a custom header menu to the column, inside it you can add a `GridColumnMenuFilter` with a `filterUI` prop that receives a custom component to display inside the filter:

columnMenu={(props)=><GridColumnMenuFilter {...props} filterUI={CustomFilterUI} /> }

I changed the example from my previous answer so that it contains a header menu with a NumericTextBox which comes from the CustomFilterUI component:

Regards,
Yanko
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.

Jie
Top achievements
Rank 3
Iron
Iron
Iron
commented on 05 Sep 2024, 03:26 PM

Hi Yanko,

That makes sense. If I want to have all the features in the original numeric filter, such as a dropdown list with options like "Is equal to" (see the attached screenshot), I will need to implement that in the custom filter, correct?

Thanks,

Jie

Yanko
Telerik team
commented on 09 Sep 2024, 01:20 PM

Hello, Jie

Yes, you are correct if you want the mentioned options you need to implement a custom filter. I suggest using the source code of the default filter if you seek similar behaviour. Here is an article from our documentation that explains how to obtain the source code: 

You can find the code files from the columnMenu inside this directory once you have cloned the repo: 

../kendo-react-private/packages/grid/src/columnMenu 

If you need further help, please open a private ticket in our portal, so we can provide you with further help:

Regards,
Yanko
Progress Telerik
Tags
Filter  Grid
Asked by
Jie
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Yanko
Telerik team
Share this question
or