Available in the OSS Version
Combo Box - Grouping
This sample demonstrates grouping functionality in the igCombo control.
This sample uses CTP (Community Technical Preview) features. The API and behavior may change when these features are released with full support.
This sample is designed for a larger screen size.
On mobile, try rotating your screen, view full size, or email to another device.
Grouping functionality allows certain items to be grouped and distinguished by category, such an employee and the department that he belongs to.
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/structure/infragistics.css" rel="stylesheet" /> <link type="text/css" href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/themes/metro/infragistics.theme.css" rel="stylesheet" /> <link type="text/css" href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/structure/modules/infragistics.ui.shared.css" rel="stylesheet" /> <link type="text/css" href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/structure/modules/infragistics.ui.combo.css" rel="stylesheet" /> <link type="text/css" href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/structure/modules/infragistics.ui.validator.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> <!-- Bootstrap tooltips require Tether --> <script src="/js/external/tether.min.js"></script> <script src="/data-files/Customers.js"></script> <style> .dropdown-menu { list-style-type: none; } #test { position: absolute; margin-left: 100px; margin-top: 50px; top: 33px; left: 135px; } body { font-size: 14px; } </style> </head> <body> <div id='combo'></div> <br> <script type="text/javascript"> $(function () { ApplyStyle() }); $('#combo').igCombo({ dataSource: data, closeDropDownOnBlur: false, width: "250px", textKey: 'name', valueKey: 'id', grouping: { key: 'state', dir: 'desc' }, headerTemplate: "<div style='text-align:center;'><table style='width: 100%; background-color: #c0c0c0'>" + "<tr>" + "<td colspan='2' style='text-align:center'> </td>" + "</tr>" + "<tr>" + "<td colspan='2'>" + "<div class='btn-group' role='group' aria-label='...'>" + "<div class='btn-group' role='group'>" + "<button type='button' class='btn btn-secondary dropdown-toggle' data-toggle='dropdown' aria-expanded='false'>" + "Group by" + "<span class='caret'></span>" + "</button>" + "<ul class='dropdown-menu' role='menu'>" + "<li><a class='dropdown-item' href='#' onclick='GroupBy(\"state\")'>State</a></li>" + "<li><a class='dropdown-item' href='#' onclick='GroupBy(\"division\")'>Division</a></li>" + "</ul>" + "</div>" + "<button type='button' class='btn btn-secondary' onclick='ChangeDirection()'>Change direction</button>" + "</div>" + "</div>" + "</td>" + "</tr>" + "<tr><td colspan='2'> </tr>" + "</table></div>", footerTemplate: "<div style='text-align:center; background-color: #c0c0c0'>Customers [{0}]</div>" }); function GroupBy(key) { $("#combo").igCombo("option", "grouping", { key: key, dir: "asc" }); $("#combo").igCombo("dataBind"); ApplyStyle(); } function ChangeDirection() { var gr = $("#combo").igCombo("option", "grouping"); if (gr.dir === "desc") { gr.dir = "asc"; } else { gr.dir = "desc"; } $("#combo").igCombo("option", "grouping", gr); $("#combo").igCombo("dataBind"); ApplyStyle(); } function ApplyStyle() { $('li.ui-igcombo-group-header').css({ 'color' : '#00AADE', 'font-weight' : 'bold' }); } </script> </body> </html>
var data = [{ "id": 0, "division": "East", "name": "Russ Martin", "address": "MT,VT, NH, ME (all firms)", "state": "MT", "coordinates": "43.299428,-74.217933", }, { "id": 1, "division": "East", "name": "Carey Fischer", "address": "NY- Upstate ex Rockland County (BD, FP)", "state": "NY", "coordinates": "46.879682,-110.362566" }, { "id": 2, "division": "East", "name": "Brandon Born", "address": "CT, NY - Upstate, MA - ex metro Boston (FI), MA - Central, West (all firms)", "state": "CT", "coordinates": "40.714353,-74.005973" }, { "id": 3, "division": "East", "name": "Joe Tocyloski", "address": "PA - East, NJ - South (FP)", "state": "PA", "coordinates": "41.603221,-73.087749" }, { "id": 4, "division": "East", "name": "Phil Hemery", "address": "NJ (FI), NJ - Bergen County (all firms), NY - NYC (FI,RIA)/Westchester (FI,BD)/Rockland County (all firms)", "state": "NJ", "coordinates": "41.203456,-77.189941" }, { "id": 5, "division": "East", "name": "Bob Mancini", "address": "MA - East (all firms)", "state": "MA", "coordinates": "42.407235,-71.383667" }, { "id": 6, "division": "East", "name": "Damien Ramondo", "address": "NJ, PA East", "state": "NJ", "coordinates": "41.203456,-77.189941" }, { "id": 7, "division": "West", "name": "Kevin Gang", "address": "W VA,PA - West (all firms), OH - Cleveland (BD, FI)", "state": "VA", "coordinates": "44.314844,-85.602364" }, { "id": 8, "division": "West", "name": "Andrew Fischer", "address": "MI - (all firms)", "state": "MI", "coordinates": "40.057052,-74.404907" }, { "id": 9, "division": "East", "name": "David Saslowsky", "address": "NYC", "state": "NY", "coordinates": "46.879682,-110.362566" }, { "id": 10, "division": "East", "name": "Robert Brazofsky", "address": "NYC", "state": "NY", "coordinates": "46.879682,-110.362566" }, { "id": 11, "division": "West", "name": "Joseph Proscia", "address": "NJ - North ex Bergen County, NY - NYC (FP)", "state": "NJ", "coordinates": "41.203456,-77.189941" }, { "id": 12, "division": "West", "name": "Niki Proscia", "address": "NJ - North ex Bergen County, NY - NYC (FP)", "state": "NJ", "coordinates": "41.203456,-77.189941" }, { "id": 13, "division": "East", "name": "Matt Proscia", "address": "NJ - North ex Bergen County, NY - NYC (FP)", "state": "NJ", "coordinates": "41.203456,-77.189941" }, { "id": 14, "division": "East", "name": "Nate Proscia", "address": "NJ - North ex Bergen County, NY - NYC (FP)", "state": "NJ", "coordinates": "41.203456,-77.189941" }, { "id": 15, "division": "West", "name": "Ralf Proscia", "address": "NJ - North ex Bergen County, NY - NYC (FP)", "state": "NJ", "coordinates": "41.203456,-77.189941" }, { "id": 16, "division": "West", "name": "Proscia Joseph", "address": "NJ - North ex Bergen County, NY - NYC (FP)", "state": "NJ", "coordinates": "41.203456,-77.189941" }];