在 jqgrid 表的每一行上设置数据属性 [英] Setting data attribute on each row of a jqgrid table
问题描述
我正在使用 jqGrid,我正在尝试为每个 tr 添加一个 data- 属性.我正在触发 loadComplete 事件,但我不确定如何修改每一行.有代码示例吗?
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?
推荐答案
您可以使用 rowattr
将 any 附加属性分配给 <tr>
元素(参见答案和这个 用于代码示例).例如,您可以使用
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)};
}
将完整的输入行数据保存为 data-mydata
属性.我建议您结合使用 rowattr`` 与
gridview: true` 选项以获得最佳性能结果()
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 ()
演示使用上面的rowattr
cade,你可以看到网格的行有额外的 data-mydata
属性:
The demo uses above rowattr
cade and you can see that rows of grid have additional data-mydata
attribute:
这篇关于在 jqgrid 表的每一行上设置数据属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!