Forum
11:57
Moderators
30/10/2007
Hello,
You can try to use setColProp to change the rowattr function before to use setRowData.
This can be something like this:
// this is the new rowattr function
function newrowattrset(..)
{
...
}
...
$("#grid").jqGrid('setColProp', 'mycolname', {rowattr: newrowattrset});
$("#grid").jqGrid('setRowData',....);
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
10:12
Moderators
30/10/2007
Hello,
Can you please show us with code how you do this. The code with ajax and the dynamic code too?
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
22:24
17/04/2014
My grid (this works fine):
<script language="javascript">
jQuery('#objednavky').jqGrid({
hoverrows:false,
gridview:true,
scrollPaging:true,
rowNum:100,
rowList:[20,50,100,500],
sortname:'doklad',
sortorder:'desc',
toolbarfilter: true,
url: {link loadGrid!},
datatype:'json',
colNames:[ 'Doklad','Objednávka','Datum','IÄŒO','Zákazník','Kód','Plat','Splat','Suma','Suma s DPH','Potvrz','Dod','Odsouhlaseno'],
colModel :[
{ name:'doklad', index:'doklad', width:120, align:'left'},
{ name:'objednavka', index:'objednavka', width:70, align:'left'},
{ name:'dat_por', index:'dat_por', width:80, align:'left'},
{ name:'ico', index:'ico', width:70, align:'left'},
{ name:'zkraceny_nazev', index:'zkraceny_nazev', width:170, align:'left'},
{ name:'zakazka', index:'zakazka', width:40},
{ name:'typ_uhrady', index:'typ_uhrady', width:40},
{ name:'splatnost', index:'splatnost', width:40},
{ name:'cena_bez_dph', index:'cena_bez_dph', width:80, formatter:currencyFormatter},
{ name:'cena_celkem', index:'cena_celkem', width:80, formatter:currencyFormatter},
{ name:'potvrzeno', index:'potvrzeno', width:40},
{ name:'dodano', index:'dodano', width:40},
{ name:'odsouhlaseno', index:'odsouhlaseno', width:40, hidden:true},
],
rowattr: function (rd) {
if ((rd.dodano == "Ne") && (rd.potvrzeno == "Ano")) {
return {"style": "background-color:#FFFF99;"};
}
if (rd.dodano == "ÄŒást") {
return {"style": "background-color:#CCFF99;"};
}
if (rd.dodano == "Ano") {
return {"style": "background-color:#99FF66;"};
}
}
});
</script>
Now tha data change code (button code):
$.ajax({ url:'\/objednavky\/?do=potvrd&doklad='+id })
.done(function(d) {
$('#objednavky').jqGrid('setRowData',id, d.rowData );
});
This callback changes potvrzeno to "Ano", but the rowattr formatter doesn't reformat it...
Is is now clear, what is the problem?
10:48
Moderators
30/10/2007
Hello,
Yes - it is clear now. Thanks for posting the code.
rowattr event fire only when a new row is inserted, but not when it is updated.
The event will fire when you use addRowData.
To do what you want you will need set the attribute of the row using jQuery.
Kind Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
09:59
Moderators
30/10/2007
Hello,
If you know the id of the row and the grid id then you can
$("#rowId","#gridId").css("property","value");
Kind regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
15:52
17/04/2014
Thank you for your help, I did it this way, if someone is interested...
<script language="javascript">
function rowStyle(rd) {
if ((rd.dodano == "Ne") && (rd.potvrzeno == "Ano")) { // verify that the testing is correct in your case
return {"style": "background-color:#FFFF99;"};
}
if (rd.dodano == "ÄŒást") { // verify that the testing is correct in your case
return {"style": "background-color:#CCFF99;"};
}
if (rd.dodano == "Ano") { // verify that the testing is correct in your case
return {"style": "background-color:#99FF66;"};
}
return {"style": ""};
}
function objednavkyPotvrd(grid,id){
$.ajax({ url:'\/objednavky\/?do=potvrd&doklad='+id })
.done(function(d) {
//set columns returned by ajax call
$('#'+grid).jqGrid('setRowData',id, d.rowData );
//get the whole row
var rd = $('#'+grid).jqGrid ('getRowData', id);
//set the row css
$('#'+id).attr(rowStyle(rd));
});
}
jQuery('#objednavky').jqGrid({
hoverrows:false,
gridview:true,
scrollPaging:true,
rowNum:100,
rowList:[20,50,100,500],
sortname:'doklad',
sortorder:'desc',
toolbarfilter: true,
url: {link loadGrid!},
datatype:'json',
colNames:[ 'Doklad','Objednávka','Datum','IÄŒO','Zákazník','Kód','Plat','Splat','Suma','Suma s DPH','Potvrz','Dod','Odsouhlaseno'],
colModel :[
{ name:'doklad', index:'doklad', width:120, align:'left'},
{ name:'objednavka', index:'objednavka', width:70, align:'left'},
{ name:'dat_por', index:'dat_por', width:80, align:'left'},
{ name:'ico', index:'ico', width:70, align:'left'},
{ name:'zkraceny_nazev', index:'zkraceny_nazev', width:170, align:'left'},
{ name:'zakazka', index:'zakazka', width:40},
{ name:'typ_uhrady', index:'typ_uhrady', width:40},
{ name:'splatnost', index:'splatnost', width:40},
{ name:'cena_bez_dph', index:'cena_bez_dph', width:80, formatter:currencyFormatter},
{ name:'cena_celkem', index:'cena_celkem', width:80, formatter:currencyFormatter},
{ name:'potvrzeno', index:'potvrzeno', width:40},
{ name:'dodano', index:'dodano', width:40},
{ name:'odsouhlaseno', index:'odsouhlaseno', width:40, hidden:true},
],
rowattr: function (rd) {
return rowStyle(rd);
},
});
Most Users Ever Online: 715
Currently Online:
41 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66