【发布时间】:2019-11-13 16:40:41
【问题描述】:
我正在尝试使用 DevExtreme jQuery 构建一个多选下拉列表。我查看了 DevExpress 网站上的演示,它们使用 TreeView 或 DropDownBox 内的网格。修改该代码,这是我写的:
$('#list1').dxDropDownBox({
showClearButton: true,
valueExpr: 'Value',
displayExpr: 'Text',
dataSource: new DevExpress.data.ArrayStore({
data: source,
key: 'Value'
}),
contentTemplate: function (e) {
var value = e.component.option("Value"),
$list = $("<div>").dxList({
dataSource: e.component.option("dataSource"),
valueExpr: 'Value',
displayExpr: 'Text',
showSelectionControls: true,
selectionMode: "all",
selectedItemKeys: value,
onSelectionChanged: function (e) {
var selectedKeys = e.component.option("selectedItemKeys");
e.component.option("Value", selectedKeys);
}
});
return $list;
},
});
源是具有两个属性的对象数组(Text 和 Value 在这里相同,但有时可能不同):
[{"Text":"2000","Value":"2000"},{"Text":"2005","Value":"2005"}]
列表按原样显示,但我有两个问题:
- 当我在列表中选择一个或多个项目时,下拉框中不显示所选项目的文本(在演示中,它显示为逗号分隔的文本)。
- 我已将 list1 元素放入 HTML 表单(不是 DevExtreme 表单)中,但我不知道如何使用表单发布所选值(甚至在 jQuery 中获取它们)。
【问题讨论】:
标签: jquery drop-down-menu multi-select devextreme