This is a migrated thread and some comments may be shown as answers.

Filter Row Textbox for Int column with no decimals

4 Answers 206 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Frans
Top achievements
Rank 1
Veteran
Iron
Frans asked on 13 Apr 2021, 07:41 AM

Hi,

Im am working on a grid with some Integer data columns in it (like customer Id), including filtering in the top row of the grid (thus with.Filterable(ftb => ftb.Mode(GridFilterMode.Row)); )
By default, I see decimals in the filter textbox, like 16.00.

How can I remove those decimals (just plain int) ? So that I see just 16 instead of 16.00.

I tried a lot. Like setting format to "#", "N0", "n0", "0:N0", "0:n0", etc. Also a suggestion about a javascript function coupled. But nothing seems to work.

My code is now something like this:

columns.Bound(colInfo.Name)
                        .Title(colInfo.Title)
                        .Width(colInfo.PixelWidth)
                        .Format(colInfo.DataFormat)
                        ;

 

best regards,

Martin

 

4 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 15 Apr 2021, 08:42 AM

Hello Martin,

 

Thank you for writing to us.

There are 2 ways of achieving this requirement:

1. Creating a template:
- https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/columns.filterable.cell#columnsfilterablecelltemplate

- https://docs.telerik.com/aspnet-core/api/Kendo.Mvc.UI.Fluent/GridColumnFilterableCellSettingsBuilder#templatesystemfuncsystemobjectsystemobject

2. Accessing the generated numbox manually via javascript and removing the decimals by re-creating the widget:
https://docs.telerik.com/kendo-ui/api/javascript/ui/numerictextbox/configuration/decimals

Feel free to give it a try and let me know how it goes.

 

Regards,
Eyup
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

0
Frans
Top achievements
Rank 1
Veteran
Iron
answered on 16 Apr 2021, 09:05 AM

Thanks Eyup,

Those solutions might work, but I want it simpler. 

I dont want to mess with jQuery or css, I just want a serverside property where I can simply set this number of decimals.

Its just too trivial to do it in such a inefficient way.

 

best regards,

Martin

 

0
Frans
Top achievements
Rank 1
Veteran
Iron
answered on 19 Apr 2021, 08:06 AM

Hi Eyup / Telerik,

I found a working solution in another thread. This code below worked for me.

However, I still think this should become simpler. As a .Net MVC developer, you want to code and tweak as little as possible in jQuery, kendo client lib, and css.
I think a Integer column should have 0 decimals by default in the filter row. Without any hassle with clientcode like this.

------------------------------------------------------------------------------------
MVC Serverside code

 columns.Bound(colInfo.Name)
                            .Filterable(ftb => ftb
                                .Cell(cell => cell
                                .Operator("eq")
                                .ShowOperators(false)
                                .Template("integerFilter")
                            ))
                            .Title(colInfo.Title)
                            .Width(colInfo.PixelWidth)
----------------------------------------------------------
With js file:

// Needed for Telerik Grid number column with no decimals (Integer)
function integerFilter(e) {
    e.element.kendoNumericTextBox({
        spinners: false,
        format: "#",
        decimals: 0
    });
};

0
Eyup
Telerik team
answered on 21 Apr 2021, 08:49 AM

Hello Frans,

 

I am glad that you've managed to resolve the issue with a more preferable approach. Thank you for sharing it with our community.

Exposing this setting on the column level is a nice idea and you can log it in our Public Portal for more traction:
https://feedback.telerik.com/aspnet-mvc

 

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

Tags
Grid
Asked by
Frans
Top achievements
Rank 1
Veteran
Iron
Answers by
Eyup
Telerik team
Frans
Top achievements
Rank 1
Veteran
Iron
Share this question
or