Ho creato la seguente griglia ExtJS.Come modificare il colore del testo di una sola riga in una griglia ExtJS?
Desidero modificare il colore del testo di tutte le celle nella riga secondo.
Tuttavia, posso solo trovare il modo di cambiare il colore di tutti celle in tutti righe incluso il testo di intestazione, come mostrato qui:
var myData = [
[4, 'This is a whole bunch of text that is going to be word-wrapped inside this column.', 0.24, 3.0, '2010-11-17 08:31:12'],
[16, 'Computer2-this row should be red', 0.28, 2.7, '2010-11-14 08:31:12'],
[5, 'Network1', 0.02, 2.5, '2010-11-12 08:31:12'],
[1, 'Network2', 0.01, 4.1, '2010-11-11 08:31:12'],
[12, 'Other', 0.42, 5.0, '2010-11-04 08:31:12']
];
var myReader = new Ext.data.ArrayReader({}, [{
name: 'id',
type: 'int'
}, {
name: 'object',
type: 'object'
}, {
name: 'status',
type: 'float'
}, {
name: 'rank',
type: 'float'
}, {
name: 'lastChange',
type: 'date',
dateFormat: 'Y-m-d H:i:s'
}]);
var grid = new Ext.grid.GridPanel({
region: 'center',
style: 'color:red', //makes ALL text in grid red, I only want one row to be red
store: new Ext.data.Store({
data: myData,
reader: myReader
}),
columns: [{
header: 'ID',
width: 50,
sortable: true,
dataIndex: 'id',
hidden: false
}, {
header: 'Object',
width: 120,
sortable: true,
dataIndex: 'object',
renderer: columnWrap
}, {
header: 'Status',
width: 90,
sortable: true,
dataIndex: 'status'
}, {
header: 'Rank',
width: 90,
sortable: true,
dataIndex: 'rank'
}, {
header: 'Last Updated',
width: 120,
sortable: true,
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
dataIndex: 'lastChange'
}],
viewConfig: {
forceFit: true
},
title: 'Computer Information',
width: 500,
autoHeight: true,
frame: true,
listeners: {
'rowdblclick': function(grid, index, rec){
var id = grid.getSelectionModel().getSelected().json[0];
go_to_page('edit_item', 'id=' + id);
}
}
});
Che cosa devo fare per cambia il colore del testo solo delle celle nella seconda fila?
Nessuna offesa a Lionel intesa, ma tu non vuoi farlo in quel modo. Vuoi usare getRowClass per implementare quella logica - ecco perché è lì. La sua modifica dice anche che il suo metodo fallirebbe se il tuo negozio recupera i dati da remoto. – McStretch
Dipende da quanto generico desidera raggiungere. Se tutto ciò di cui ha bisogno è un trucco sporco, allora è quello.Se ha bisogno di una correzione a lungo termine, la tua è migliore. :) –
Haha sono un po 'd'accordo, tranne che gli hack sporchi tendono a tornare indietro e morderti nel culo un giorno. Preferisco farlo per primo e "fatto bene", soprattutto se in seguito sarà necessario aggiungere altri stili. – McStretch