Setting data attribute on each row of a jqgrid table

jqgrid

Solution

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 with`gridview: 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:

Problem

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?

Original source

Related problems