PDA

View Full Version : Grid removeClass for cell after edit..



staka
15 Nov 2007, 7:20 AM
I have a grid.. and after edit the grid, the cell I edited has a class 'x-grid-dirty-cell', and this class makes a little red triangle in the left up corner.. I want after edit the grid, to remove this class from that cell..




var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({ url: 'some_url' }),
reader: new Ext.data.JsonReader({
root: 'root',
totalProperty: 'all',
id: 'id'
},[
{name: 'id', type: 'int'},
{name: 'name'},
{name: 'moderation', type: 'int'},
{name: 'gallery', type: 'int'},
{name: 'pop_vote', type: 'int'},
{name: 'tagging', type: 'int'},
{name: 'resources', type: 'int'},
{name: 'main_pic', type: 'int'}
]),
pruneModifiedRecords: true
});

var fm=Ext.form, Ed=Ext.grid.GridEditor;

var cm = new Ext.grid.ColumnModel([
{id: 'name', header: "Име", dataIndex: 'name', width: 100, editor: new Ed(new fm.TextField({ allowBlank: false }))},
{header: "Moderation", dataIndex: 'moderation', renderer: status, editor: statCombo},
{header: "Gallery", dataIndex: 'gallery', renderer: status, editor: statCombo},
{header: "Pop vote", dataIndex: 'pop_vote', renderer: status, editor: statCombo},
{header: "Tagging", dataIndex: 'tagging', renderer: status, editor: statCombo},
{header: "Resources", dataIndex: 'resources', renderer: status, editor: statCombo},
{header: "Main pic", dataIndex: 'main_pic', renderer: status, editor: statCombo}
]);
var statCombo = new Ed(new Ext.form.ComboBox({
mode: 'local',
typeAhead: true,
triggerAction: 'all',
lazyRender: true,
store: new Ext.data.SimpleStore({
data: [
['не е пуснат',0],
['пуснат',1]
],
fields: ['statTxt','statNum']
}),
displayField: 'statTxt',
valueField: 'statNum',
selectOnFocus: true,
editable: false,
forceSelection: true,
//listWidth: 100
}));
function status(q) { return q==0?'<span style="color: #CC0000;">не е пуснат</span>':'пуснат'; };
cm.defaultSortable = true;
cm.defaultSortable = true;

var grid = new Ext.grid.EditorGrid('list_art_types', {
ds: ds,
cm: cm,
selModel: new Ext.grid.CellSelectionModel(),
enableColLock: false,
loadMask: true,
autoHeight: true,
autoExpandColumn: 'name'
});
grid.render();

grid.on('afteredit', function(q) {
var editRow=q.record.data;
var id=editRow.id;
var name=editRow.name;
var moderation=editRow.moderation;
var gallery=editRow.gallery;
var pop_vote=editRow.pop_vote;
var tagging=editRow.tagging;
var resources=editRow.resources;
var main_pic=editRow.main_pic;
$.post("/admin/modules/articles/mod_articles.php?edit_art_types=1", {id:id, name:name, moderation:moderation, gallery:gallery, pop_vote:pop_vote, tagging:tagging, resources:resources, main_pic:main_pic});
});


I tried

grid.on('afteredit', function() {
grid.getView().el.removeClass('x-grid-dirty-cell');
});
but it doesn't work..

tryanDLS
15 Nov 2007, 7:46 AM
Look at the rendered HTML in firebug. Gridview().el is not a cell - you need to find the cell in the row you're looking at and remove the class from that element. Read the afteredit doc to understand what args are passed to your handler.