How to auto select *all* items in dependent jQuery multiselect dropdown lists?

时间:2015-10-31 00:09:06

标签: jquery multi-select

My requirement is that when I select Customer ComboBox, I need to be able to auto-select all items in the dependent jquery multiselect dropdown lists. Following is what I started with. Thanks for suggestion/help ! This is Mvc View: <td> @if(ViewBag.Customer != null) { @( Html.Telerik().ComboBox() .Name("ddlCustomer") .BindTo((IEnumerable<SelectListItem>)ViewBag.Customer) .ClientEvents(ce => ce.OnChange("ddlCustomer_OnChange")) ) } </td> <td> @if (ViewBag.Service != null) { @Html.DropDownList("ddlService", (IEnumerable<SelectListItem>)ViewBag.Service, new { onchange = "ServiceChange()" }) } </td> <td> @if (ViewBag.Type != null) { @Html.DropDownList("ddlType", (IEnumerable<SelectListItem>)ViewBag.Type, new { onchange = "ComponentChange()" }) } </td> <td> @if (ViewBag.SubType != null) { @Html.DropDownList("ddlSubType", (IEnumerable<SelectListItem>)ViewBag.SubType) } </td> //.js file function ddlCustomer_OnChange(){ var goldCustomer = "Gold Customer"; var ddlCustomerCombo = $(this).data('tComboBox'); var selectedOption = ddlCustomerCombo.text(); if (selectedOption == goldCustomer){ //I want to get all items auto-selected in ddlService $("#ddlService").multiselect("checkAll"); //I want to get all items auto-selected in ddlType //which are based on all the checked items in #ddlService $("#ddlType").multiselect("checkAll"); //I want to get all items auto-selected in ddlSubType //which are based on all the checked items in #ddlType $("#ddlSubType").multiselect("checkAll"); } }; Above .multiselect("checkAll") for ddlType and ddlSubType is not working, even though ddlService is working. Any suggestion is appreciated. Thanks!!

0 个答案:

没有答案