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

Rebind Combobox after disable/enable sequence

2 Answers 263 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 18 Dec 2015, 12:57 AM

Working w/a C# MVC Project that displays a Company's information if the user chosen from a ComboBox EXISTS.  One of the data fields displayed is the Company's State which is itself a ComboBox:

@(Html.Kendo().ComboBox()
                            .Name("CompanyState")
                            .Placeholder("Select a state...")
                            .BindTo((List<string>)ViewBag.StateNames)
                            .Value("NV")
                            .Suggest(true)
                        )

Note that when the ComboBox is first created, its data source is bound to the List in "ViewBag.StateNames". 

When the data is displayed, I DISABLE the "CompanyState" ComboBox as there is no need for the App User to enter the data.

$("#CompanyState").kendoComboBox({ enabled: false });

My problem is when I need to ENABLE the "CompanyState", I lose the binding to the List in "ViewBag.StateNames". My question then is: how can I rebind to that List?

2 Answers, 1 is accepted

Sort by
0
Accepted
Nencho
Telerik team
answered on 21 Dec 2015, 01:34 PM
Hello Aaron,

Using the approach that you have demonstrated :

$("#CompanyState").kendoComboBox({ enabled: false });

You are initializing a new widget, with its enabled state set to false. You can consider using the following approaches for disabling and enabling the kendoComboBox:
$("#CompanyState").data("kendoComboBox").enable(false// disable
$("#CompanyState").data("kendoComboBox").enable(true// enable

This approach is demonstrated in our documentation article below:

http://docs.telerik.com/kendo-ui/api/javascript/ui/combobox#methods-enable


Regards,
Nencho
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Aaron
Top achievements
Rank 1
answered on 21 Dec 2015, 05:08 PM
Thanks Nencho!
Tags
ComboBox
Asked by
Aaron
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Aaron
Top achievements
Rank 1
Share this question
or