我有一个带easyui的数据网格,我动态创建标题,因为它们依赖于我的数据库。我已经把我的头了。这是传递给datagrid的json对象。
[[
{"field": "status","title": "Estatus","align": "center","rowspan": "2"},
{"field": "Numero","title": "Orden","align": "center","rowspan": "2"},
{"field": "FechaRegistro","title": "Fecha","align": "center","rowspan": "2"},
{"field": "T1","title": "00:02:00","align": "center"},
{"field": "T2","title": "00:24:00","align": "center"},
{"field": "T3","title": "00:04:00","align": "center"},
{"field": "T4","title": "02:00:00","align": "center"},
{"field": "Cierre","title": "Fecha y Hora<br \/>de Cierre","align": "center","rowspan": "2"}
],[
{"field": "P1","title": "Informacion <br\/>tecnica para <br\/>aprobacion","align": "center","styler": "formatColor"},
{"field": "P2","title": "Aprobacion de<br\/> Informacion<br\/>Tecnica cliente","align": "center","styler": "formatColor"},
{"field": "P3","title": "Informacion<br\/>Tecnica de<br\/>Proceso","align": "center","styler": "formatColor"},
{"field": "P4","title": "Compra y<br\/>Recepcion de<br\/>Materiales","align": "center","styler": "formatColor"}
]]
我在.js中有一个功能
function formatColor(val,row,lol){
var col = "";
for(var name in row){
col = "";
var value = row[name];
if(value === val){
col = name;
}
if(col !=="" && val!==""){
var opts = $('#dg').datagrid('getColumnOption',col);
var pr =opts["field"].substring(1);
var opts2 = $('#dg').datagrid('getColumnOption', 'T'+pr);
var time = opts2["title"];
if(val >= time){
return 'background-color:#ff0000;color:white;';
}
else{
return 'background-color:#00ff00;color:white;';
}
}
}
return val;
}
但我在我的控制台中将其作为错误。
Uncaught TypeError: col.styler is not a function
我的网格每秒都会在P1,P2,P3,P4列中填充查询,T1,T2,T3,T4就是该列应该建立的时间。所以我试图做到这一点,如果我的列值高于它将成为红色背景。我已经成功地将这项工作放在一个小提琴上,问题是这里的标题不是动态加载的,那就是它使它不起作用(从我所看到的)这里是小提琴link
这就是我设置标题的方式。
function RefreshHeaders(){
$.ajax({
url:"includes/getHeader.php",
cache: false,
timeout: 5000,
async: true,
success: function(data){
//console.log(data);
var objekJSON=jQuery.parseJSON(data);
$('#dg').datagrid({
fit:true,
fitColumns:false,
columns:objekJSON,
url:"includes/Get_Orders.php"
});
}
});
}
谢谢,