Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting data attribute on each row of a jqgrid table

Tags:

jqgrid

I am using jqGrid and I'm trying to add a data- attribute to each tr. I'm firing the loadComplete event, but I'm unsure of how to modify each row. Any code samples?

like image 771
Mike Cole Avatar asked Aug 16 '13 19:08

Mike Cole


1 Answers

You can use rowattr to assign any additional attribute to <tr> elements (see the answer and this one for code examples). For example you can use

rowattr: function (rd) {
    return {"data-mydata": JSON.stringify(rd)};
}

to save full input row data as data-mydata attribute. I recommend you to use rowattr``in combination withgridview: true` option to have the best performance results ()

The demo uses above rowattr cade and you can see that rows of grid have additional data-mydata attribute:

enter image description here

like image 71
Oleg Avatar answered Sep 30 '22 13:09

Oleg