kendo ui - Persisting the default value of the numeric text after deleting entered value -
have @ sample here. problem have need have 0.00 value remain in numerictextbox though value deleted in control. @ moment appears empty on ui. can advise cleanest solutions problem?
you can achieve goal wiring change event of widget , modify value , model's 1 when triggered.
<div id="view"> <div data-template="containertpl" data-bind="source: people"></div> <button data-bind="click: addnew">add</button> </div> <script id="containertpl" type="text/x-kendo-template"> <div> <label for="firstname#:id#">name</label> <input name="firstname#:id#" type="text" data-bind="value: firstname"/> <input data-role="numerictextbox" data-bind="value: income, events: { change: numericchange }"/> </div> </script> var viewmodel = kendo.observable({ people: [ {id: 1, firstname: "", income: "0.00" }, {id: 2, firstname: "", income: "0.00" }, {id: 3, firstname: "", income: "0.00" } ], numericchange: function(args) { var numeric = args.sender; if (numeric.value() === null) { numeric.value(0); args.data.set("income", 0); } } }); viewmodel.addnew = function(){ viewmodel.people.push({id: viewmodel.people.length + 1, firstname: "generated", income: "0.00"}); }; $(document).ready(function(){ kendo.bind($("#view"), viewmodel); });
Comments
Post a Comment