我将一些数据属性放入表行标记中。当我将表格设置为wijgrid时,数据属性会被销毁。
如何防止wijmo破坏这些属性?
发布于 2012-01-05 18:20:24
当在行上应用属性(tr)时,它们会被插件忽略(正如你所经历的),不管它们是什么(样式、类、数据...)。
这似乎是自愿的,因为在插件源代码中注释了,这段代码通常会提取行的属性。
在方法readTableSection中,我们有(我在这里删除了不相关的代码行):
readTableSection: function(table, section, readAttributes) {
...
if (table && (section = this.getTableSection(table, section))) {
for (ri = 0, rowLen = section.rows.length; ri < rowLen; ri++) {
row = section.rows[ri];
tmp = [];
if (readAttributes) {
// here normally the html attributes of the rows (<tr>) should be extracted
// but the code is commented !
tmp.rowAttributes = null; // $.wijmo.wijgrid.getAttributes(row);
tmp.cellsAttributes = [];
}
// here is extracted the html attributes for the cells (<td>)
for (ci = 0, celLen = row.cells.length; ci < celLen; ci++) {
tmp[ci] = row.cells[ci].innerHTML;
if (readAttributes) {
tmp.cellsAttributes[ci] = $.wijmo.wijgrid.getAttributes(row.cells[ci], prevent);
}
}
result[ri] = tmp;
}
}
return result;
}我对td元素的"data-“属性进行了测试,它们没有被销毁。
注意:您必须使用选项readAttributesFromData。
你可以联系开发这个插件的公司,询问他们为什么要注释掉这一行。
https://stackoverflow.com/questions/8720528
复制相似问题