具体关于jqgrid表格内下拉框的数据源

//动态生成select内容 

function GetWar() {
var str = "";
$.ajax({
//type: "post",
async: false,
url: "/WmsManage/Warehouse/GetSelectJson",
success: function (data) {//通过后台获取到到数据源
console.info(data);
if (data != null) {//如果不为空,就循环遍历数据源
var jsonobj = eval(data);
var length = jsonobj.length;
for (var i = 0; i < length; i++) {
if (i != length - 1) {
str += jsonobj[i].id + ":" + jsonobj[i].text + ";";
} else {
str += jsonobj[i].id + ":" + jsonobj[i].text;// 这里是option里面的 value:label ,我的是Id,text
}
}
}
}
});
return str;
}

获取到完整的数据源,value直接调用即可

{
label: '选择仓库', name: 'F_WarehouseId', width: 60, align: 'center', editable: true,
edittype: "select", editoptions: { value: GetWar() },
},

猜你喜欢

转载自www.cnblogs.com/ChenXuYuanLen/p/9770997.html