Search code examples
knockout.jskendo-uiknockout-kendo

Beginner issue with knockout-kendo.js


I've used kendo UI quite a bit and have been using knockout.js recently. I'm trying to use the library knockout-kendo.js to render kendo inputs using knockout bindings. I'm trying to make a simple numeric input formatted for currency and with the spinners disabled. I feel like I must be missing something obvious but here is my simple binding:

<input type="text" 
       data-bind="kendoNumericTextBox: { spinners: false, format: 'c0' }" />

It is successfully rendering a kendo numeric text box but with the default kendo options, not currency, spinners enabled, etc.


Solution

  • The default option for that binding is value. When it doesn't find a valueproperty on the options, then it assumes that you are binding directly against value. This means that you options are getting passed through.

    The easiest fix is to either bind against some value like:

    <input type="text" 
       data-bind="kendoNumericTextBox: { value: myValue, spinners: false, format: 'c0' }" />
    

    or if you really don't want to bind a value, then you can do:

    <input type="text" 
       data-bind="kendoNumericTextBox: { value: null, spinners: false, format: 'c0' }" />