Monday, December 15, 2014

How to update an EditorFor that uses a kendo NumericTextBoxFor control.

Easy to get a value using .val(), but to set the value you have to call the change event of the control and navigate away from it in order to save the changes to the model!

 @Html.EditorFor(model => model.PVR, "Number")

Here's the editorTemplate named "Number":

@model double?
@using Kendo.Mvc.UI
@(Html.Kendo().NumericTextBoxFor(m => m)
.Decimals(3)
.Format("0.000")
      .HtmlAttributes(new { style = "width:100%" })
)


here's the jscript code to update the value:

var kendo = $("#PVR").data("kendoNumericTextBox");
            kendo.value(output);
            kendo.trigger("change");
            var target = $("#Wedge").data("kendoNumericTextBox");
            target.siblings("input:visible").focus();

1 comment:

  1. Buy and sell titanium wire wire for your vehicle - Titanium
    We 토토 사이트 추천 also have a variety of options for many buyers, and are titanium welding also titanium water bottle available oakley titanium glasses online. microtouch trimmer For many, we've added our own unique “titanium”

    ReplyDelete