EasyUI 1.3.3版:我想知道如何将valueField(即用户选择选项后将在组合框中显示的内容)设置为组名和项目名的混合(例如Grp1-item1 )。
var data = [
{group:'Group1',items:[
{value:'v11',text:'Option11'},
{value:'v12',text:'Option12'},
{value:'v13',text:'Option13'},
{value:'v14',text:'Option14'}
]},
{group:'Group2',items:[
{value:'v21',text:'Option21'},
{value:'v22',text:'Option22'},
{value:'v23',text:'Option23'},
{value:'v24',text:'Option24'}
]}
];
function loadFilter(data){
var dd = [];
for(var i=0; i<data.length; i++){
var group = data[i].group;
dd.push({
group:group,
text:group
});
dd = dd.concat(data[i].items);
}
return dd;
}
function onLoadSuccess(){
var groupItems = $(this).combobox('panel').find('div.combobox-item:has(span.combobox-group-text)');
groupItems.removeClass('combobox-item');
}
function formatter(row){
if (row.group){
return '<span class="combobox-group-text" style="font-weight:bold">'+row.group+'</span>';
} else {
return '<span style="padding-left:10px">'+row.text+'</span>';
}
}
$(function(){
$('#cc').combobox({
data:data,
loadFilter:loadFilter,
formatter:formatter,
onLoadSuccess:onLoadSuccess
});
});