在jqgrid表的每一行上设置数据属性 [英] Setting data attribute on each row of a jqgrid table

查看:71
本文介绍了在jqgrid表的每一行上设置数据属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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``in combination with gridview:true`选项以获得最佳性能结果()

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 ()

该演示使用的是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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆