Это быстрое исправление, которое вводит новое свойство для meta
в PivotGridView
, чтобы впоследствии его можно было использовать для отката индексов ячеек. Большая часть кода не отличается, просто введение meta.id
в renderRows
и разбиение meta.id
в getCellIndex
.
Ext.override(Ext.grid.PivotGridView, {
renderRows : function(startRow, endRow) {
var grid = this.grid,
rows = grid.extractData(),
rowCount = rows.length,
templates = this.templates,
renderer = grid.renderer,
hasRenderer = typeof renderer == 'function',
getCellCls = this.getCellCls,
hasGetCellCls = typeof getCellCls == 'function',
cellTemplate = templates.cell,
rowTemplate = templates.row,
rowBuffer = [],
meta = {},
tstyle = 'width:' + this.getGridInnerWidth() + 'px;',
colBuffer, column, i;
startRow = startRow || 0;
endRow = Ext.isDefined(endRow) ? endRow : rowCount - 1;
for (i = 0; i < rowCount; i++) {
row = rows[i];
colCount = row.length;
colBuffer = [];
rowIndex = startRow + i;
//build up each column's HTML
for (j = 0; j < colCount; j++) {
cell = row[j];
meta.id = i + '-' + j;
meta.css = j === 0 ? 'x-grid3-cell-first ' : (j == (colCount - 1) ? 'x-grid3-cell-last ' : '');
meta.attr = meta.cellAttr = '';
meta.value = cell;
if (Ext.isEmpty(meta.value)) {
meta.value = ' ';
}
if (hasRenderer) {
meta.value = renderer(meta.value);
}
if (hasGetCellCls) {
meta.css += getCellCls(meta.value) + ' ';
}
colBuffer[colBuffer.length] = cellTemplate.apply(meta);
}
rowBuffer[rowBuffer.length] = rowTemplate.apply({
tstyle: tstyle,
cols : colCount,
cells : colBuffer.join(""),
alt : ''
});
}
return rowBuffer.join("");
},
getCellIndex : function(el) {
if (el) {
var match = el.className.match(this.colRe),
data;
if (match && (data = match[1])) {
return parseInt(data.split('-')[1], 10);
}
}
return false;
}
});