This is a migrated thread and some comments may be shown as answers.

Combobox does not respect 'autoBind: false' option when control value is set

1 Answer 445 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Curt
Top achievements
Rank 1
Curt asked on 14 Nov 2012, 12:56 AM
I have a combobox bound to a viewmodel and configured to use a remote datasource for the list of choices as follows:
input.kendoComboBox({
    dataTextField: 'label',
    dataValueField: 'id',
    autoBind: false,
    dataSource: {
        type: "json",
        serverFiltering: true,
        transport: {
            read: {
                url: 'api/getchoices,
                data: {
                    filter: function(){
                             return input.val();
                    }
                }
            }
        }
    }
});
<input data-role="combobox" data-bind="value: id, comboboxText:idText"/>
As seen above, the the combobox is configured as "autoBind: false".  This value is respected for those comboboxes on the page which have no value (in the viewmodel) but for those comboboxes that do have a value, the combobox will immediately query the remote server when the page loads.  This is undesirable from a performance perspective, and also unnecessary since both the dataTextField and dataValueField are being set from the viewmodel.

Is it a bug that autoBind: false is not being respected?  How can I suppress this unnecessary call to the remote datasource?

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 14 Nov 2012, 03:48 PM
Hello Curt,

 
The ComboBox/DropDownList will initiate binding if the value() method is used. The MVVM value binding on the other hand uses the value method of the widget to set its value. Hence after the widget is initialized and the binding is avoid because of the autoBind setting, the value binding will trigger dataSource binding anyway. Use a custom value binding in order to avoid this default behavior.

Kind regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ComboBox
Asked by
Curt
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or