更新时间:2022-11-02 23:22:53
旧但尚未解决.
嗨. 是的,jqGrid的内部table
和td
存在问题,但是有一个快速而有用的修复程序.在文件jquery.jqGrid.min
(jqGrid 3.8.2-jQuery Grid)中.将文件放入 js-beutifier 或获取未缩小的版本,然后找到getRowData
函数.然后,您必须为每个b("td", r).each(function (t) {
的查找添加额外条件,以对 b("td[id!='-1']", r).each(function (t) {
进行编码.在内部表中,您应该声明<td id="-1">
.在这种情况下,您将td排除在colModel
中.
Hi. Yes jqGrid has problem with inner table
and td
but there is a quick and useful fix. In file jquery.jqGrid.min
(jqGrid 3.8.2 - jQuery Grid). Put file into js-beutifier or get not minified version and find getRowData
function. Then you have to add extra condition to lookup foreach b("td", r).each(function (t) {
to code b("td[id!='-1']", r).each(function (t) {
. In your inner table you should declare <td id="-1">
. In this case you exclude your td from searching in colModel
.
复制/粘贴此代码:
getRowData: function (f) {
var j = {},
i, c = false,
e, k = 0;
this.each(function () {
var n = this,
a, r;
if (typeof f == "undefined") {
c = true;
i = [];
e = n.rows.length
} else {
r = n.rows.namedItem(f);
if (!r) return j;
e = 2
}
for (; k < e;) {
if (c) r = n.rows[k];
if (b(r).hasClass("jqgrow")) {
b("td[id!='-1']", r).each(function (t) {//fix
a = n.p.colModel[t].name;
if (a !== "cb" && a !== "subgrid" && a !== "rn") if (n.p.treeGrid === true && a == n.p.ExpandColumn) j[a] = b.jgrid.htmlDecode(b("span:first", this).html());
else try {
j[a] = b.unformat(this, {
rowId: r.id,
colModel: n.p.colModel[t]
}, t)
} catch (B) {
j[a] = b.jgrid.htmlDecode(b(this).html())
}
});
if (c) {
i.push(j);
j = {}
}
}
k++
}
});
return i ? i : j
}
最后要在其中放置内部表的位置:
Finally where you want to put inner table do this:
<table>
<tr>
<td id="-1">
Now It's working!
</tr>
<td id="-1">
Yeah
</tr>
</tr>
</table>
当然您可以更改id
属性,但是由于jQuery针对class
属性的性能,我建议使用html id
属性修复此问题.
Of course you can change id
attribute but I recommend fix this with html id
attribute due to jQuery performance against class
attribute.