Your search did not match any results.
DropDownBox

Multiple Selection

Documentation
The DropDownBox widget is an editor that consists of a text field and drop-down content. The content can be anything. In this demo, it is the TreeView widget and the DataGrid widget. This demo also illustrates how to implement multiple selection and how to synchronize the DropDownBox with the nested widgets.
Copy to CodePen
Apply
Reset
$(function(){ var treeView, dataGrid; var syncTreeViewSelection = function(treeView, value){ if (!value) { treeView.unselectAll(); return; } value.forEach(function(key){ treeView.selectItem(key); }); }; var makeAsyncDataSource = function(jsonFile){ return new DevExpress.data.CustomStore({ loadMode: "raw", key: "ID", load: function() { return $.getJSON("../../../../data/" + jsonFile); } }); }; $("#treeBox").dxDropDownBox({ value: ["1_1"], valueExpr: "ID", displayExpr: "name", placeholder: "Select a value...", showClearButton: true, dataSource: makeAsyncDataSource("treeProducts.json"), contentTemplate: function(e){ var value = e.component.option("value"), $treeView = $("<div>").dxTreeView({ dataSource: e.component.option("dataSource"), dataStructure: "plain", keyExpr: "ID", parentIdExpr: "categoryId", selectionMode: "multiple", displayExpr: "name", selectByClick: true, onContentReady: function(args){ syncTreeViewSelection(args.component, value); }, selectNodesRecursive: false, showCheckBoxesMode: "normal", onItemSelectionChanged: function(args){ var value = args.component.getSelectedNodesKeys(); e.component.option("value", value); } }); treeView = $treeView.dxTreeView("instance"); e.component.on("valueChanged", function(args){ var value = args.value; syncTreeViewSelection(treeView, value); }); return $treeView; } }); $("#gridBox").dxDropDownBox({ value: [3], valueExpr: "ID", placeholder: "Select a value...", displayExpr: "CompanyName", showClearButton: true, dataSource: makeAsyncDataSource("customers.json"), contentTemplate: function(e){ var value = e.component.option("value"), $dataGrid = $("<div>").dxDataGrid({ dataSource: e.component.option("dataSource"), columns: ["CompanyName", "City", "Phone"], hoverStateEnabled: true, paging: { enabled: true, pageSize: 10 }, filterRow: { visible: true }, scrolling: { mode: "infinite" }, height: 265, selection: { mode: "multiple" }, selectedRowKeys: value, onSelectionChanged: function(selectedItems){ var keys = selectedItems.selectedRowKeys; e.component.option("value", keys); } }); dataGrid = $dataGrid.dxDataGrid("instance"); e.component.on("valueChanged", function(args){ var value = args.value; dataGrid.selectRows(value, false); }); return $dataGrid; } }); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/> <script src="js/jquery-3.1.0.min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.1.7/css/dx.spa.css"/> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.1.7/css/dx.common.css"/> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/17.1.7/css/dx.light.css"/> <link rel="dx-theme" data-theme="android5.light" href="https://cdn3.devexpress.com/jslib/17.1.7/css/dx.android5.light.css"/> <link rel="dx-theme" data-theme="ios7.default" href="https://cdn3.devexpress.com/jslib/17.1.7/css/dx.ios7.default.css"/> <link rel="dx-theme" data-theme="win10.black" href="https://cdn3.devexpress.com/jslib/17.1.7/css/dx.win10.black.css"/> <link rel="dx-theme" data-theme="win10.white" href="https://cdn3.devexpress.com/jslib/17.1.7/css/dx.win10.white.css"/> <script src="https://cdn3.devexpress.com/jslib/17.1.7/js/dx.all.js"></script> <script src="data.js"></script> <link rel="stylesheet" type="text/css" href="styles.css"/> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="form"> <div class="dx-fieldset"> <div class="dx-field"> <div class="dx-field-label">DropDownBox with embedded TreeView</div> <div class="dx-field-value"> <div id="treeBox"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">DropDownBox with embedded DataGrid</div> <div class="dx-field-value"> <div id="gridBox"></div> </div> </div> </div> </div> </div> </body> </html>