3

I am using the Kendo UI (2015.3.930) Grid Control and I have a integer textbox in a grid filter row that always as decimal when I apply the filter.

Here is my code:

@(Html.Kendo().Grid((IEnumerable<UiController.Lot>)Model.Lots)
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.LotNumber).Title("Lot No")
            .Filterable(ftb =>ftb.ItemTemplate("NumericFilter"));
        columns.Bound(c => c.BranchName).Title("Branch Name");
    })
    .HtmlAttributes(new { style = "height: 530px;" })
    .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
    .DataSource(dataSource => dataSource
        .Server()
        .Model(model => { model.Id(p => p.Id); })
    )
)

My script section shows:

<script>
    function NumericFilter(args) {
        args.element.kendoNumericTextBox({
            "spinners": false,
            "format": "n0",
            "decimals": 0,
        });
    }
</script>

For an integer value of 10, it shows '10.00' after the applying the filter. Is there a way of showing the value without the decimal portion.

2 Answers 2

1

I have prepared Dojo example just to show that it is possible.

I have not MVC wrappers but it looks, that it will work if you will do some small modifications to your code:

1] Change ItemTemplate in your Filterable to UI

columns.Bound(c => c.LotNumber).Title("Lot No").Filterable(ftb => ftb.UI("NumericFilter"));

2] Then you should be able to get wanted behaviour with syntax you showed in question with small (selector) modification

<script>
function NumericFilter(args) {
$(args).kendoNumericTextBox({
    "spinners" : false,
    "format": "n0",
    "decimals": 0,
});
}
Sign up to request clarification or add additional context in comments.

Comments

1

to customize this field, you need to use cell.template, please update your code as follow:

columns.Bound(c => c.LotNumber)
    .Title("Lot No")
    .Filterable(ftb => ftb.Cell(c => c.Template("NumericFilter")));

2 Comments

Great @Luis, please, mark this answer to help other users with this problem.
and it would be better to use format: "g" in your js function because when textbox loses the focus, it shows a number like 12,345.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.