I have a datagrid with easyui, I dynamically create headers, as they depend on my database. I already got my headline. this is a json object passed to datagrid.
[[
{"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"}
]]
and I have a function in my .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;
}
but I get this in my console as an error.
Uncaught TypeError: col.styler is not a function
my grid is filled with a query every second with several times in columns P1, P2, P3, P4, T1, T2, T3, T4 - this is just the set time this column should take. So I am trying to do this, if the value of my column is higher than it, it will become a red background. I managed to do this work on the violin, the problem is that the headers here are not loading dynamically, and here is what makes it inoperable (from what I saw) here is the violin link
And so I set the headers.
function RefreshHeaders(){
$.ajax({
url:"includes/getHeader.php",
cache: false,
timeout: 5000,
async: true,
success: function(data){
var objekJSON=jQuery.parseJSON(data);
$('#dg').datagrid({
fit:true,
fitColumns:false,
columns:objekJSON,
url:"includes/Get_Orders.php"
});
}
});
}
Thanks,