小弟使用easyui,做了个combobox,可以看到下拉框内的选项,但有的选项无法选中,请问如何应对?
html代码<select id="selScore1" class="easyui-combobox" panelheight="auto" data-options="valueField:'id',textField:'text'" style="width:auto;"></select>
加载选项的js代码:var currScoreStr = [{"id":"4.00","text":"参加教科研活动(共4分)","selected":"true"},{"id":"4.00","text":"参加学校活动情况(共4分)"},{"id":"8.00","text":"出勤(共8分)"}]"
$("#selScore1").combobox("loadData", currScoreStr);
运行后,发现有的分数无法选中,例如:本来选中的是"出勤(共8分)",但显示的是上面的"参加学校活动情况(共4分)"(只是举例)
html代码<select id="selScore1" class="easyui-combobox" panelheight="auto" data-options="valueField:'id',textField:'text'" style="width:auto;"></select>
加载选项的js代码:var currScoreStr = [{"id":"4.00","text":"参加教科研活动(共4分)","selected":"true"},{"id":"4.00","text":"参加学校活动情况(共4分)"},{"id":"8.00","text":"出勤(共8分)"}]"
$("#selScore1").combobox("loadData", currScoreStr);
运行后,发现有的分数无法选中,例如:本来选中的是"出勤(共8分)",但显示的是上面的"参加学校活动情况(共4分)"(只是举例)
请详细点
例子:
//公共供应商列表 cid 控件id funName 对应处理方法
function bindSupplier(cId, funName) {
//绑定供应商控件
$(cId).combobox({
valueField: 'SupplierID',
textField: 'SupplierName',
url: '../../Service/AccessoryService.ashx?methodName=' + funName,
filter: function (q, row) {
var opts = $(this).combobox("options");
return row[opts.textField].indexOf(q) > -1;
},
onLoadSuccess: function (data) {
if (data.Message) {
if (data.Success == true) {
if (data.Data.length > 0) {
$(cId).combobox('loadData', data.Data).combobox("setValue", data.Data[0].SupplierID);//加载后台json数据源 并默认选中
if (data.Data.length == 1) {
$(cId).combobox("disable");
canEdit = false;
}
}
} else {
$.messager.alert("程序错误", data.Message, "error");
}
}
}
});
}