The NumericTextBox widget allows for editing a variety of numeric value types.
This example demonstrates passing a single option to bind against the value of the NumericTextBox widget.
<input data-bind="kendoNumericTextBox: price" />
<hr/>
Price: <strong data-bind="text: price"> </strong>
var ViewModel = function() {
this.price = ko.observable(10.50);
};
ko.applyBindings(new ViewModel());
This example demonstrates passing additional options in the data-bind attribute with value now being explicitly specified.
<input type="checkbox" data-bind="checked: enabled" /> Enabled<br/>
<input class="input-mini" data-bind="value: min" /> Min<br/>
<input class="input-mini" data-bind="value: max" /> Max<br/>
<hr/>
<input data-bind="kendoNumericTextBox: { value: price, enabled: enabled, min: min, max: max, format: 'c' }" />
<hr/>
Price: <strong data-bind="text: price"> </strong>
var ViewModel = function() {
this.price = ko.observable(10.50);
this.enabled = ko.observable(true);
this.min = ko.observable(0);
this.max = ko.observable(100);
};
ko.applyBindings(new ViewModel());
This example demonstrates setting global options in ko.bindingHandlers.kendoNumericTextBox.options. This helps to simplify the markup for settings that can be used as a default for all instances of this widget.
<input type="checkbox" data-bind="checked: enabled" /> Enabled<br/>
<hr/>
<input data-bind="kendoNumericTextBox: { value: price, enabled: enabled }" />
<hr/>
Price: <strong data-bind="text: price"> </strong>
var ViewModel = function() {
this.price = ko.observable(10.50);
this.enabled = ko.observable(true);
};
ko.bindingHandlers.kendoNumericTextBox.options = {
min: 0,
max: 100,
format: 'c'
};
ko.applyBindings(new ViewModel());