I am trying to create a cascading effect with 2 comboboxes.
The first combobox contains states and the second contains cities in those states. When the user chooses a state, the second combobox should only display cities that are in that selected state.
I am trying to clear the datasource and reset it, but I am not having much luck.
Is it possible to do what I am trying to do?
Thanks!
Bobby
Hi Bobby,
I am glad you found solution with destroy.
About failure to change dataSource: I experimented with the most latest version, and it is possible that igCombo had some issues with changing dataSource, which already have been fixed.
I really have got to stop posting so quickly :)
I did some more research and found that if I destory the combo first and then re-initialize it, it works as expected.
$('#cities').igCombo('destroy');$('#cities').igCombo({ valueKey: 'city', textKey: 'city', dataSource: window['cities' + name]});
There appears to be an issue with just updating the datasource directly...
Again, thanks for you assistance.
Hi Viktor!
First off, thanks for the example. However, I am having issues getting it to work properly. I understand exactly what you are trying to accomplish, but when I 'reset' the datasource it causes the dropdown to never show.
i.e. I default the cities combo to show all cities, then when the select the 'state', I swap out the datasource with the state specific one. When I do this, the dropdown with values no longer displays. I can tell that the datasource has not changed because if I type in a name of a city that is not in that state and move focus from the combo, the city will still display.
I think my issue has more to do with changing of the datasource of the comobox. I am using your example code. Is it possible that there is a bug with resetting the datasource? I am using version: 11.2.20112.1023
Hi Georgi,
Thank you for a sample.I tested that with few adjustments (with few adjustments, see below) and it worked as you probably expected.When item in country-combo was selected, then second combo appeared with cities which corresponded to selected country. When selection in country-combo was cleared, then city-combo disappeared.
Notes:1. You probably use old version of Infragistics.Web.Mvc dll. The latest/new version will have implementation of combo, editors and rating similar to rules used by standard Mvc controls such as TextBox, DropDownList, etc. Those controls will expect that model contains named member/field. That rule will be applied to Combo(id), ComboFor(model), TextEditor(id), TextEditorFor(model), etc.The old empty constructor without named field will be still supported as a remainder from old version. That usage will be not advisable and it will not have support for persistance after a postback.If application will attempt to use ComboFor(model) or Combo(id) without member in model, then exception will be raised.
2. In order to run your sample, I replaced ComboFor(model => model[0].igCombo2)byCombo()Considering structure of your model (List) it is possible to use (better to say "misuse") ComboFor with something likeComboFor(model => model[0].igCombo2)Assuming that DropDownItem will have igCombo2 member. Something likepublic class DropDownItem{ public string Country { get; set; } public string City { get; set; } public string igCombo2 { get; set; } ...}So, I tested those cases.
Hello Striker8118,
I just developed a sample demonstrating this.
I am attaching the sample here,
Download it and let me know your comments.
Looking forward to hear from you.
Sincerely,
Georgi Sashev
Developer Support Engineer
Infragistics, Inc.
http://es.infragistics.com/support