PDA

View Full Version : EditorGridPanel, custom renderer and repaint



MrITT
1 Feb 2010, 2:47 AM
Hi

I am using a EditorGridPanel with a custom render function.
When values are below a threshold, the color of the cell changes

But when the threshold changes, all cells needs to be repainted.
I can't get this working.

Things i have ried:
grid.render(), no joy.
Reloading the store: grid.getStore().reload() gives an error. (this.proxy is undefined)




for (var d = 2; d < histColumns.length; d++) {
gridColumns.push(new Ext.grid.Column({
header: histColumns[d].header,
summaryType: histColumns[d].summaryType !== undefined ? histColumns[d].summaryType : historyData.summaryType,
align: 'right',
width: 30,
sortable: true,
renderer: gridRendererColor,
dataIndex: histColumns[d].dataIndex
}));
}

function gridRendererColor(val, x, y, row, column, oo){
if (isNaN(val)) {
return '-';
}
else {
if (y.json === undefined) { // total column.. skip
return val;
}
var color = cellBackground;
try {
var cell = historyData.historyTable.getCell(y.json.dataPtr, column - 1);
color = cell.color;
}
catch (err) {

}
userLog.addLine("Color : " + color);
return '<span style="color:#' + colorBlack + ';background:#' + color + ';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + val + '</span>';
}
}


var reader = new Ext.data.JsonReader({
fields..... not relevant
});

var summary = new Ext.ux.grid.GroupSummary();

var grid = new Ext.grid.EditorGridPanel({
ds: new Ext.data.GroupingStore({
reader: reader,
// use local data
data: data2,
sortInfo: {
field: 'groupText',
direction: 'ASC'
},
groupField: 'groupText'
}),
columns: gridColumns,

view: new Ext.grid.GroupingView({
forceFit: true,
showGroupName: false,
enableNoGroups: false,
enableGroupingMenu: false,
hideGroupedColumn: true
}),
plugins: [summary],
border: false,
animCollapse: false,
trackMouseOver: false,
items: []
});



Thx :)

MrITT
1 Feb 2010, 3:14 AM
Well at least it's working for me.



var store = grid.getStore();
for (var j = 0; j < numberOfRecs; j++) {
store.fireEvent("update", store, store.getAt(j), Ext.data.Record.COMMIT);
}

VinylFox
1 Feb 2010, 5:05 AM
The more standard way would be...


grid.getView().refresh()

All the visuals that happen in a Grid are controlled by the View (GridView)

MrITT
1 Feb 2010, 5:19 AM
Thanks, that's better