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

Editing NumericTextBox in a Grid and Calling an Action when User Clicks off the NumericTextBox

1 Answer 159 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Nicholas asked on 19 Jul 2017, 03:53 PM

There are two parts to this question:

First, I am trying to add a column to the grid that looks normal, but will turn into a NumericTextBox when clicked into, and back to normal when clicked out. Originally, before I added .ClientTemplate, the cell looked normal and then would turn into a basic textbox when I click into it. After adding the .ClientTemplate, what shows up is a textbox initially (strange), that will SOMETIMES turn into a NumericTextBox when I click into it. There is no telling when this will happen or not. Additionally, if it does happen to turn into a NumericTextBox, when I click on the up or down arrows, the value will change for about .10 seconds and the switch back to the original value.

Second, I want an action to run that will redirect through my controller to update the model after I click off the NumericTextBox so that everything stays up to date. I do not want to have an "update" button because that is too inconvenient for the user, who will be trying to fill out the form as fast as possible.

Here is my Kendo Grid code (it should be noted that my onChangeNumeric function never fires):

.DataSource(dataSource => dataSource //Configure the Grid data source.
    .Ajax() //Specify that Ajax binding is used.
    .Read(read => read.Action("GetCurrentIngredients", "NewMaterial").Data("rawPaperGridFunctionRef"))
    .Events(events => events.Error("error_handler"))
    .Model(model =>
        model.Id (p => );
        model.Field(p =>;
        model.Field(p => p.percent).Editable(true);
.Columns(columns =>
    columns.Command(ingredient => ingredient
        .Text(" ")
        .HtmlAttributes(new { title = "Delete Ingredient",
            style = "height:32px;width:32px;min-width:32px;min-height:32px;background-image:url('"
                + Url.Content("~/Images/if_Delete_1493279.png")
                + "');background-color:rgba(0, 0, 0, 0);border-color:rgba(0, 0, 0, 0);",
            functionRef = "DeleteRawPaperIngredient"}))
    columns.Bound(ingredient =>"Raw Ingredient");
    columns.Bound(ingredient => ingredient.percent).Title("Percent %").Width(200).ClientTemplate(Html.Kendo().NumericTextBox<float>()
        .HtmlAttributes(new { value = "#=percent#" })
        .Events(ev => ev.Change("onChangeNumeric"))
.Editable(x => x.Mode(GridEditMode.InCell))
.Sortable() // Enable sorting
.Scrollable(scr => scr.Height(173))
    type = "grid",
    functionRef = "DeleteRawPaperIngredient",
    gridRef = "#RawPaperGrid"

1 Answer, 1 is accepted

Sort by
Viktor Tachev
Telerik team
answered on 21 Jul 2017, 10:28 AM
Hi Nicholas,

I have examined the provided code and noticed that the InCell mode is enabled. With this mode when the user clicks on a cell it will enter edit mode. 

The ClientTemplate that is defined for a column would show the data in preview mode. However it would not be used for editing the underlying field.

To specify what editor would be used for a field you can configure custom editor templates. Please check out the article below that illustrates how to specify editor template for bound fields in the Grid. 

Regarding the requirement for saving the changes automatically. For this you can handle the cellClose event of the Grid. In the event handler you can call saveChanges() in order to force the Grid component to save the modifications. The code would look similar to the following:

$(function () {
    var grid = $("#RawPaperGrid").data("kendoGrid");
    grid.bind("cellClose", function (e) {

Have in mind that the cellClose event was introduced in R2 2017 version of the controls. Thus, in order to use it you need to ensure that the version of the components is 2017.2.504 or later.

Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Asked by
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question