I want to put numerictextbox in my kendo grid. So, i decide to use Editor Templates. It's work because when i run it, the numerictextbox appear. However, after i insert some number, the number will show, but if i click anywhere, the number will dissapear as i'm not insert anything.
this is my code in index.
@(Html.Kendo().Grid((IEnumerable<DDLnetcore.Models.Product>)ViewBag.Product)
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.Name).Width(100);
columns.Bound(p => p.Price).EditorTemplateName("Numeric");
columns.Command(command => command.Destroy()).Width(150);
})
.ToolBar(toolBar =>
{
toolBar.Create();
toolBar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Scrollable()
.Sortable()
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.PageSize(20)
.ServerOperation(false)
.Events(events => events
.Error("errorHandler")
)
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.Price);
})
.Read(read => read.Action("Index", "Products"))
.Update(update => update.Action("Buatdata", "Products"))
.Create(create => create.Action("Buatdata", "Products"))
.Destroy(destroy => destroy.Action("Destroy", "Products"))
)
)
and this is my editor templates code
@model DDLnetcore.Models.Product
@(Html.Kendo().NumericTextBoxFor<decimal>(m => m.Price)
.Format("c")
.Min(0)
.Max(100)
)
the code in index already read my editor templates code, because of that the numerictextbox shown. but the data is not bound. is there anything wrong in my code?
I already found the problem. The problem is in my editor templates. For those who have same problem, try change to this code in editor templates.
@model decimal
@(Html.Kendo().NumericTextBoxFor<decimal>(m => m)
.Format("c")
.Min(0)
.Max(100)
)
Thank you.