You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You should synchronize the DropDownBox UI component with an embedded element. The following instructions show how to do it when the embedded element is another DevExtreme UI component, but they are also applicable in other cases.
1
+
To use DropDownBox with an embedded UI component, synchronize the two components' data and selection state. The steps below use an embedded DataGrid as an example. The same approach applies to other DevExtreme UI components.
2
2
3
3
1.**Specify data sources**
4
-
The DropDownBox's and embedded UI component's data sources can be the same or different. If they are different, the UI component's key field should be present in the DropDownBox's data source.
4
+
The DropDownBox and embedded UI componentcan have the same data source or different data sources. If the data sources are different, the UI component's key field must be present in the DropDownBox data source.
5
5
6
6
<!--JavaScript-->
7
7
// Different data sources, both have the ID field
@@ -16,8 +16,8 @@ The DropDownBox's and embedded UI component's data sources can be the same or di
16
16
// ...
17
17
];
18
18
19
-
1.**Specify which data field provides the DropDownBox's values and the embedded UI component's keys**
20
-
Assign the field's name to the DropDownBox's [valueExpr](/api-reference/10%20UI%20Components/DataExpressionMixin/1%20Configuration/valueExpr.md'/Documentation/ApiReference/UI_Components/dxDropDownBox/Configuration/#valueExpr') property and to the [key](/api-reference/30%20Data%20Layer/Store/1%20Configuration/key.md'/Documentation/ApiReference/Data_Layer/ArrayStore/Configuration/#key') property of the embedded UI component's store. The following example shows an [ArrayStore](/api-reference/30%20Data%20Layer/ArrayStore'/Documentation/ApiReference/Data_Layer/ArrayStore/'):
19
+
1.**Specify the shared key field**
20
+
Assign the field's name to the DropDownBox's [valueExpr](/api-reference/10%20UI%20Components/DataExpressionMixin/1%20Configuration/valueExpr.md'/Documentation/ApiReference/UI_Components/dxDropDownBox/Configuration/#valueExpr') property and to the [key](/api-reference/30%20Data%20Layer/Store/1%20Configuration/key.md'/Documentation/ApiReference/Data_Layer/ArrayStore/Configuration/#key') property of the embedded UI component's store. The following example uses an [ArrayStore](/api-reference/30%20Data%20Layer/ArrayStore'/Documentation/ApiReference/Data_Layer/ArrayStore/'):
21
21
22
22
---
23
23
##### jQuery
@@ -49,15 +49,23 @@ Assign the field's name to the DropDownBox's [valueExpr](/api-reference/10%20UI%
49
49
valueExpr="ID"
50
50
displayExpr="email"
51
51
[dataSource]="dropDownBoxData">
52
-
<dx-data-grid ...
52
+
<dx-data-grid
53
53
[dataSource]="gridDataSource">
54
54
</dx-data-grid>
55
55
</dx-drop-down-box>
56
56
57
57
<!--TypeScript-->
58
-
import { DxDropDownBoxModule, DxDataGridModule } from "devextreme-angular";
58
+
import { Component } from "@angular/core";
59
+
import { DxDropDownBoxComponent } from "devextreme-angular/ui/drop-down-box";
60
+
import { DxDataGridComponent } from "devextreme-angular/ui/data-grid";
59
61
import ArrayStore from "devextreme/data/array_store";
import { DropDownBox } from 'devextreme-react/drop-down-box';
129
-
import { DataGrid, Selection } from "devextreme-react/data-grid";
130
-
import ArrayStore from "devextreme/data/array_store";
131
-
132
-
const dropDownBoxData = {/* ... */};
117
+
import { DataGrid} from 'devextreme-react/data-grid';
118
+
import ArrayStore from 'devextreme/data/array_store';
119
+
120
+
const dropDownBoxData = [/* ... */];
133
121
const gridDataSource = new ArrayStore({
134
122
data: widgetData,
135
-
key: "ID"
123
+
key: 'ID',
136
124
});
137
125
138
-
class App extends React.Component {
139
-
render() {
140
-
return (
141
-
<DropDownBox
142
-
dataSource={dropDownBoxData}
143
-
valueExpr="ID"
144
-
displayExpr="email">
145
-
<DataGrid ...
146
-
dataSource={gridDataSource}
147
-
/>
148
-
</DropDownBox>
149
-
);
150
-
}
126
+
export default function App() {
127
+
return (
128
+
<DropDownBox
129
+
dataSource={dropDownBoxData}
130
+
valueExpr="ID"
131
+
displayExpr="email">
132
+
<DataGrid dataSource={gridDataSource} />
133
+
</DropDownBox>
134
+
);
151
135
}
152
136
153
-
export default App;
154
-
155
137
##### ASP.NET MVC Controls
156
138
157
139
<!--Razor C#-->
@@ -175,9 +157,9 @@ Assign the field's name to the DropDownBox's [valueExpr](/api-reference/10%20UI%
175
157
---
176
158
177
159
1.**Synchronize the DropDownBox's value and the embedded UI component's selection**
178
-
This step's implementation depends on the embedded UI component's API and the library/framework you use. If the library/framework supports two-way binding, you can bind the DropDownBox's [value](/api-reference/10%20UI%20Components/dxDropDownBox/1%20Configuration/value.md'/Documentation/ApiReference/UI_Components/dxDropDownBox/Configuration/#value') and the UI component's **selectedRowKeys**/**selectedItemKeys** to the same variable. If not, handle events as follows:
160
+
The synchronization implementation depends on the embedded UI component's API and the library/framework you use. If the library/framework supports two-way binding, you can bind the DropDownBox's [value](/api-reference/10%20UI%20Components/dxDropDownBox/1%20Configuration/value.md'/Documentation/ApiReference/UI_Components/dxDropDownBox/Configuration/#value') and the UI component's **selectedRowKeys**/**selectedItemKeys** to the same variable. If not, handle events as follows:
179
161
1. **Set the initial selection in the embedded UI component**
180
-
Implement the UI component's **onContentReady** handler to select data items according to the DropDownBox's initial value. In some UI components, you can set the **selectedRowKeys** or **selectedItemKeys**option instead.
162
+
Implement the UI component's **onContentReady** handler to select data items according to the DropDownBox's initial value. In some UI components, you can set **selectedRowKeys** or **selectedItemKeys**directly instead of using **onContentReady**.
181
163
1. **Update the selection**
182
164
Implement the DropDownBox's [onValueChanged](/api-reference/10%20UI%20Components/dxDropDownBox/1%20Configuration/onValueChanged.md'/Documentation/ApiReference/UI_Components/dxDropDownBox/Configuration/#onValueChanged') handler to update the selection when the DropDownBox's value changes.
183
165
1. **Update the DropDownBox's value**
@@ -191,7 +173,7 @@ This step's implementation depends on the embedded UI component's API and the li
191
173
<!--JavaScript-->
192
174
$(function() {
193
175
// ...
194
-
const dataGridInstance;
176
+
let dataGridInstance;
195
177
$("#dropDownBox").dxDropDownBox({
196
178
// ...
197
179
value: [1],
@@ -217,20 +199,26 @@ This step's implementation depends on the embedded UI component's API and the li
0 commit comments