I have some data- attributes that I put into a table row tag. When I set the table to be a wijgrid the data- attributes are destroyed.
How do I keep wijmo from destroying these attributes?
When applying attributes on rows (tr
), they are simply ignored by the plugin (as you experienced), whatever they are (style, class, data...).
It seems voluntary because the piece of code that would normally extract the attributes for the rows is commented in the plugin source.
In the method readTableSection
, we have (i removed the not relevant lines of code in here):
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;
}
I have made a test with "data-" attributes on td
elements and they are not destroyed.
Note: you have to use the option readAttributesFromData
.
You may contact the company who develops this plugin to ask why they have commented out this line.