Available in the OSS Version
Combo Box - Cascading
This sample demonstrates the use of three cascading combo controls.
This sample uses CTP (Community Technical Preview) features. The API and behavior may change when these features are released with full support.
Start the automatic data filtering by selecting a Country
Country
State
District
Town
This sample is designed for a larger screen size.
On mobile, try rotating your screen, view full size, or email to another device.
Imagine that you want to find the office of a multicultural company. By selecting the value in any previous combo the next control's values are automatically filtered by the selected value in the previous combo box. This sample shows how to bind each instance of the igCombo control with separate data source.
Code View
Copy to Clipboard
<!DOCTYPE html> <html> <head> <title></title> <!-- Ignite UI for jQuery Required Combined CSS Files --> <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" /> <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/structure/infragistics.css" rel="stylesheet" /> <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script> <!-- Ignite UI for jQuery Required Combined JavaScript Files --> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.core.js"></script> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.lob.js"></script> </head> <body> <style type="text/css"> .label-container { margin: 5px 0; } span[id^="combo"] { margin-right: 15px; } #state, #stateCascading { display: none; } .group-container { padding: 10px; margin-bottom: 10px; clear: both; } .group-title { font-weight: bold; } .comboGroup { float: left; } .overHidden { overflow: hidden; } </style> <br /> <div class="group-container overHidden"> <h3>Start the automatic data filtering by selecting a Country</h3> <br /> <div class="overHidden"> <div class="comboGroup"> <div>Country</div> <span id="comboCountry"></span> </div> <div class="comboGroup"> <div id="state">State</div> <div id="district">District</div> <span id="comboDistrict"></span> </div> <div class="comboGroup"> <div>Town</div> <span id="comboTown"></span> </div> </div> </div> <script> var dsCountry, dsCascTowns, dsCountryCascading, dsCountryCascading, dsStatesUSCascading, dsDistrictBGCascading; dsCountry = [ { txtCountry: "United States", valCountry: "US" }, { txtCountry: "Bulgaria", valCountry: "BG" } ]; dsCascDistrict = [ { keyCountry: "US", txtDistrict: "New Jersey", valDistrict: "NJ" }, { keyCountry: "US", txtDistrict: "California", valDistrict: "CA" }, { keyCountry: "US", txtDistrict: "Illinois", valDistrict: "IL" }, { keyCountry: "US", txtDistrict: "New York", valDistrict: "NY" }, { keyCountry: "US", txtDistrict: "Florida", valDistrict: "FL" }, { keyCountry: "BG", txtDistrict: "Sofia", valDistrict: "SA" }, { keyCountry: "BG", txtDistrict: "Plovdiv", valDistrict: "PV" }, { keyCountry: "BG", txtDistrict: "Varna", valDistrict: "V" }, { keyCountry: "BG", txtDistrict: "Burgas", valDistrict: "B" }, { keyCountry: "BG", txtDistrict: "Stara Zagora", valDistrict: "SZ" } ]; dsCascTowns = [ { keyDistrict: "NJ", textTown: "Atlantic City", valTown: "AtlanticCity" }, { keyDistrict: "NJ", textTown: "Dover", valTown: "Dover" }, { keyDistrict: "NJ", textTown: "Paterson", valTown: "Paterson" }, { keyDistrict: "NJ", textTown: "Elizabeth", valTown: "Elizabeth" }, { keyDistrict: "NJ", textTown: "Edison", valTown: "Edison" }, { keyDistrict: "CA", textTown: "Los Angeles", valTown: "LosAngeles" }, { keyDistrict: "CA", textTown: "San Francisco", valTown: "San Francisco" }, { keyDistrict: "CA", textTown: "San Diego", valTown: "SanDiego" }, { keyDistrict: "CA", textTown: "San Jose", valTown: "San Jose" }, { keyDistrict: "CA", textTown: "Fresno", valTown: "Fresno" }, { keyDistrict: "IL", textTown: "Chicago", valTown: "Chicago" }, { keyDistrict: "IL", textTown: "Dakota", valTown: "Dakota" }, { keyDistrict: "IL", textTown: "New Canton", valTown: "New Canton" }, { keyDistrict: "IL", textTown: "Astoria", valTown: "Astoria" }, { keyDistrict: "IL", textTown: "Otterville", valTown: "Otterville" }, { keyDistrict: "NY", textTown: "New York", valTown: "NewYork" }, { keyDistrict: "NY", textTown: "Buffalo", valTown: "Buffalo" }, { keyDistrict: "NY", textTown: "Rochester", valTown: "Rochester" }, { keyDistrict: "NY", textTown: "Yonkers", valTown: "Yonkers" }, { keyDistrict: "NY", textTown: "Syracuse", valTown: "Syracuse" }, { keyDistrict: "FL", textTown: "Miami", valTown: " Miami" }, { keyDistrict: "FL", textTown: "Orlando", valTown: "Orlando" }, { keyDistrict: "FL", textTown: "Jacksonville", valTown: "Jacksonville" }, { keyDistrict: "FL", textTown: "Tampa", valTown: "Tampa" }, { keyDistrict: "FL", textTown: "St. Petersburg", valTown: "St. Petersburg" }, { keyDistrict: "SA", textTown: "Sofia", valTown: "Sofia" }, { keyDistrict: "SA", textTown: "Ihtiman", valTown: "Ihtiman" }, { keyDistrict: "SA", textTown: "Samokov", valTown: "Samokov" }, { keyDistrict: "SA", textTown: "Svoge", valTown: "Svoge" }, { keyDistrict: "SA", textTown: "Botevgrad", valTown: "Botevgrad" }, { keyDistrict: "PV", textTown: "Plovdiv", valTown: "Plovdiv" }, { keyDistrict: "PV", textTown: "Karlovo", valTown: "Karlovo" }, { keyDistrict: "PV", textTown: "Hisaria", valTown: "Hisaria" }, { keyDistrict: "PV", textTown: "Asenovgrad", valTown: "Asenovgrad" }, { keyDistrict: "PV", textTown: "Rakovski", valTown: "Rakovski" }, { keyDistrict: "V", textTown: "Varna", valTown: "Varna" }, { keyDistrict: "V", textTown: "Aksakovo", valTown: "Aksakovo" }, { keyDistrict: "V", textTown: "Beloslav", valTown: "Beloslav" }, { keyDistrict: "V", textTown: "Avren", valTown: "Avren" }, { keyDistrict: "V", textTown: "Dylgopol", valTown: "Dylgopol" }, { keyDistrict: "B", textTown: "Burgas", valTown: "Burgas" }, { keyDistrict: "B", textTown: "Karnobat", valTown: "Karnobat" }, { keyDistrict: "B", textTown: "Aytos", valTown: "Aytos" }, { keyDistrict: "B", textTown: "Sozopol", valTown: "Sozopol" }, { keyDistrict: "B", textTown: "Pomorie", valTown: "Pomorie" }, { keyDistrict: "SZ", textTown: "Stara Zagora", valTown: "Stara Zagora" }, { keyDistrict: "SZ", textTown: "Gurkovo", valTown: "Gurkovo" }, { keyDistrict: "SZ", textTown: "Chirpan", valTown: "Chirpan" }, { keyDistrict: "SZ", textTown: "Radnevo", valTown: "Radnevo" }, { keyDistrict: "SZ", textTown: "Gylybovo", valTown: "Gylybovo" }, ]; $(function () { $("#comboCountry").igCombo({ textKey: "txtCountry", valueKey: "valCountry", placeHolder: "select country...", dataSource: dsCountry, selectionChanged: function (evt, ui) { var filteredCascDistrict = []; if (ui.items && ui.items[0]) { var itemData = ui.items[0].data; if (itemData.valCountry == "US") { $("#state").css("display", "block"); $("#district").css("display", "none"); } else { $("#state").css("display", "none"); $("#district").css("display", "block"); } filteredCascDistrict = dsCascDistrict.filter(function (district) { return district.keyCountry == itemData.valCountry; }); } var $comboDistrict = $("#comboDistrict"); $comboDistrict.igCombo("deselectAll", {}, true); $comboDistrict.igCombo("option", "dataSource", filteredCascDistrict); $comboDistrict.igCombo("dataBind"); var disableChildCombo = filteredCascDistrict.length == 0; $comboDistrict.igCombo("option", "disabled", disableChildCombo); }, itemsRendered: function (evt, ui) { ui.owner.deselectAll(); } }); $("#comboDistrict").igCombo({ valueKey: "valDistrict", textKey: "txtDistrict", placeHolder: "select district...", dataSource: [], disabled: true, selectionChanged: function (evt, ui) { var filteredCascTown = []; if (ui.items && ui.items[0]) { var itemData = ui.items[0].data; var filteredCascTown = dsCascTowns.filter(function (town) { return town.keyDistrict == itemData.valDistrict; }); } var $comboTown = $("#comboTown"); $comboTown.igCombo("deselectAll"); $comboTown.igCombo("option", "dataSource", filteredCascTown); $comboTown.igCombo("dataBind"); var disableChildCombo = filteredCascTown.length == 0; $comboTown.igCombo("option", "disabled", disableChildCombo); } }); $("#comboTown").igCombo({ valueKey: "valTown", textKey: "textTown", placeHolder: "select town...", disabled: true }); }); </script> </body> </html>