easyui datagrid 动态绑定列
var fnc = function (datatable) {
var options = {
columns: [[
{
field: "rowIndex", title: "编号", align: 'center', width: 80, sortable: false, resizable: false
},
{
field: "SystemName", title: "系统", align: 'center', width: 260, sortable: false, resizable: false
}
]]
}, datatable, poolId = $("#selAssetProFilePoolId").val(), columnName = "";
for (var i = 0; i < datatable.length; i++) {
datatable[i].rowIndex = i + 1;
datatable[i].ResourceName = $("#selAssetProFilePoolId option:selected").text();
}
options.columns[0].push({ field: "VMCount", title: columnName, align: 'center', width: 80, sortable: false, resizable: false });
if (poolId < 5) {
columnName = poolId > 2 ? "测试 数据库" : "数据库测试"
options.columns[0].push({ field: "DBInstanceCount", title: columnName, align: 'center', width: 80, sortable: false, resizable: false });
options.columns[0].push({ field: "SLBCount", title: "测试负载均衡", align: 'center', width: 80, sortable: false, resizable: false });
}
if (poolId > 2 && poolId < 5) {
options.columns[0].push({ field: "OCSCount", title: "测试开放缓存服务", align: 'center', width: 80, sortable: false, resizable: false });
options.columns[0].push({ field: "DRDSCount", title: "测试分布式数据库服务", align: 'center', width: 80, sortable: false, resizable: false });
options.columns[0].push({ field: "OSSCount ", title: "测试对象存储", align: 'center', width: 80, sortable: false, resizable: false });
options.columns[0].push({ field: "ONSCount ", title: "测试开放消息服务", align: 'center', width: 80, sortable: false, resizable: false });
options.columns[0].push({ field: "OTSCount", title: "测试开放结构化数据服务", align: 'center', width: 80, sortable: false, resizable: false });
}
$("#report_datagrid").datagrid(options);
$("#report_datagrid").datagrid("loadData", { total: 1, rows: datatable });
}