Dojo - dijit multiple column in the combo box
How can I write a dijit autocomplete combo box that contains multiple columns, such as this...
- joh开发者_StackOverflown, doe, cod 13, street sample 1
- steve, smith, cod 14, street sample 2
- micheal, james, cod 14, street sample 3
This is my code:
var filteringSelect = new dijit.form.ComboBox({
id: "managerSelect",
name: "managers",
value: "",
store: managerStore,
searchAttr: "serial"
},
"managerSelect");
}
However it only shows a single column like this:
- john
- steve
- micheal
If I understand correctly,you need to override "labelFunc" for combo box. E.g.
// define combo box
var filteringSelect = new dijit.form.ComboBox({
id: "managerSelect",
name: "managers",
value: "",
store: managerStore,
searchAttr: "serial",
labelFunc:"myLabelFunc"
},
"managerSelect");
}
// define labelFunc
function myLabelFunc(item, store){
var label=store.getValue(item, 'first')+","+store.getValue(item, 'last');
return label;
}
HTML page - Example
精彩评论