Search code examples
model-view-controllerkendo-uitextboxteleriknumeric

Kendo MVC Grid Numeric Textbox


I try to show numeric text box in grid. My data is int but not showing like demos in telerik. I used client template but at this time grid has two input in same cell.

It is showing like this when I used any attributes for template.

enter image description here

here is code;

 columns.Bound(c => c.MAX_DOSYA_BOYUT)

When I use custom template it is showing like this

enter image description here

here is code;

   columns.Bound(c => c.MAX_DOSYA_BOYUT).Template(@<text></text>).ClientTemplate(

            Html.Kendo().NumericTextBox<int>()
                .Name("order_#=URETIM_YERI#")
                .HtmlAttributes(new { value = "#=MAX_DOSYA_BOYUT #", @class = "k-numerictextbox", style = "width:100%" })
                .Min(0)
                .Max(100000)
                .Step(1)
                .Decimals(0)
                .ToClientTemplate().ToHtmlString());

and it must look like at this link

telerik kendo editing

What i am doing wrong?

Thanks...


Solution

  • At first, make sure ~Views/Shared/EditorTemplates directory contains predefined kendo ui mvc editor templates. If not - copy them from wrappers/aspnetmvc/ EditorTemplates folder of your kendo ui mvc installation.

    Columns binding settings:

    columns.Bound(c => c.NumberTest).EditorTemplateName("Integer");
    

    Editor template name "Integer" corresponds with Integer.cshtml template in EditorTemplate directory. Result - fully themed widget.