2
votes

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,
    });
}

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.

Thanks,

2

2 Answers

1
votes

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,
});
}
1
votes

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")));