下拉框多选最终样式表(我这里下拉的内容是固定的,不是查询出来的):
1.由于下拉内容是固定的,因此不需要dataType和dataSet。因此,在dataGid的onReady事件:
self.set("items", view.busTypeItems);
而view.busTypeItems写在view的
onReady:
view.busTypeItems = [ {
key : 0,
value : "订舱"
}, {
key : 1,
value : "做箱"
}, {
key : 2,
value : "报关"
}, {
key : 3,
value : "提单"
}, {
key : 4,
value : "外包"
}, {
key : 5,
value : "代垫费用"
} ];
dataGid里面的value属性是自定义的
2.在CustomDropDown的onOpen事件:
var busType = view.get("#dsCondition.data:#.busType"), items = [];
if (busType != null) {
busType = busType.split(",");
view.get("#busTypeGrid.items").each(function(item) {
busType.each(function(type) {
if (type == item.key) {
items.push(item);
return false;
}
});
});
}
view.set("#busTypeGrid.selection", items);
3.“确定”按钮的onClick事件:
var selection = view.get("#busTypeGrid.selection") || [], busType = [], busTypeName = [];
selection.each(function(item) {
busType.push(item.key);
busTypeName.push(item.value);
});
view.set("#dsConditions.data:#.busType", busType.join(","));
view.get("#dsConditions").getData("#").set({
busType : busType.join(","),
busTypeName : busTypeName.join(",")
});
view.get("#busTypeCustomDropDown").close();