I populated the Kendo Combox using KnockoutJS. I am using Knockout-Kendo.js to do that.
http://rniemeyer.github.com/knockout-kendo/web/ComboBox.html
I have 2 addresses, k1 address and mailing address:
for both addresses, if you select a state from the state combo box, then the country combo is dsiabled and United States is selected.
if you delete the state from the state combo box or if you manually type in a state which doesn’t exist, the country combo box will be enabled. if you select any countries beside united states, the state combo box will be disabled.
I got that working for k1 address.
<input data-bind=" kendoComboBox: { enabled: k1Address.isStateMutable, dataTextField: 'Name', dataValueField: 'Id', data: states, value: k1Address.stateId }" />
the problem is the mailing address. There also a checkbox “Different Mailing Address”, so I need to check both conditions ( enabled: isK1MailDifferfrmAddress && mailingAddress.isStateMutable ). if I just do ( enabled: isK1MailDifferfrmAddress ) or (enabled: mailingAddress.isStateMutable) they both work. I dont know why, when I check them both, it wont work.
<input data-bind=" kendoComboBox: { dataTextField: 'Name', dataValueField: 'Id', data: states, value: mailingAddress.stateId, enabled: isK1MailDifferfrmAddress && mailingAddress.isStateMutable }" />
I uploaded my code on jsFiddle, you can test it there.
when you run it, the state and country combo box for mailing address should be disabled,but they are not.
Normally, when you use an expression that involves observables or computed observables, you need to make sure that you call each as a function like:
myoption: observableA() + computedB().However, the Kendo bindings actually do need either an observable or a computed directly (or a static value). So, you would need to have a computed that represents your enabled concept.
For example, you could pass your “different address” flag into the address constructor and use it as part of the mutable computeds that you are using.
Here is a sample: http://jsfiddle.net/rniemeyer/gatuV/6/