Highlighting modified cells - Ext JS

Jack,

I want to change the background colour of modified cells in an editable grid. The code below appears to have the desired effect to the extent that it adds the "modified" class to the cell. However, some Ext code stomps on that class and once control returns to the browser the class has gone.

I think I had this working yesterday. However when I try to debug what's going on now I get lost in the bowels of your code.

A pointer on where the problem could be arising would be very helpful.

Am I going about this the right way? Is there a better way to achieve this effect?

Thanks,

Gordon

    this.grid = new Ext.grid.EditorGrid(divId, {
        ds : ds,
        cm : cm,
        selModel : new Ext.grid.RowSelectionModel({singleSelect:true}),
        enableColLock : false,
		autoSizeColumns : false,
		monitorWindowResize : true,
		trackMouseOver : true,
		clicksToEdit : 1
    });
...
	this.grid.on('afteredit', this.afterEdit, this, true);
...
	afterEdit : function(grid, row, field, rowIndex, columnIndex){
...
		var cell = this.grid.getView().getCell(rowIndex, columnIndex);
		cell = Ext.get(cell);
		cell.addClass('modified');
	},
Reply With Quote
  #2  
Old 02-27-2007, 11:04 AM
Default

In the current rev, I would recommend doing this with a renderer:
function renderDirty(val, p, record){
    if(record.dirty && record.modified['some-column'] != undefined){
         p.css += ' some-class';
    }
    return val;
}
However, I have been working on this and in the next rev this is built in. It automatically adds a class for dirty cells (x-grid-dirty-cell) and dirty rows (x-grid-dirty-row).

Note: after you save the changes, you will need to either call commit() or reject() on the individual record(s) or call commitAll()/rejectAll() on the store in order to trigger a UI update.

The new rev should be available soon.
Reply With Quote
  #3  
Old 02-27-2007, 11:08 AM
Default

Fantastic. Thanks Jack
Reply With Quote
  #4  
Old 02-27-2007, 01:34 PM
Default

Quote:
...
if(record.dirty && record.modified
...
What is the difference between "dirty" and "modified"?
Reply With Quote
  #5  
Old 02-28-2007, 11:18 AM
Default

Dirty tracks if anything in the record has been modified and has not been committed. The "modified" collection has the original values for the field before any edits were made (to support rollback). If modified has an entry for a field, it has been modified.
Reply With Quote
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值