2012-07-12 111 views
3

我正在創建一個Extjs網格。其中大多數列是可編輯的。我需要的是,如果用戶更改模糊的任何列值,我會調用我的方法做一些計算基於其他列值,並用計算values.code替換列值。在單元格編輯器中獲取extjs中的行數據

var incomeTaxOverrideModel = new Ext.grid.ColumnModel([{ 
    id : 'fromDate', 
    header : "From Date", 
    dataIndex : 'fromDate', 
    width : 80, 
    renderer : drenderer, 
    editor : this.fromDateEditor 
}, { 
    id : 'toDate', 
    header : "To Date", 
    dataIndex : 'toDate', 
    width : 80, 
    renderer : drenderer, 
    editor : this.toDateEditor 
}, { 
    id : 'rawTax', 
    header : "Raw Tax", 
    dataIndex : 'rawTax', 
    width : 80, 
    align : 'right', 
    selectOnFocus : true, 
    editor : new Ext.form.NumberField({"blur":this.calculateTaxForword}), 
    renderer : Gts.payItemRenderer() 
}, { 
    id : 'surcharge', 
    header : "Surcharge", 
    dataIndex : 'surcharge', 
    width : 80, 
    align : 'right', 
    selectOnFocus : true, 
    editor : new Ext.form.NumberField({}), 
    renderer : Gts.payItemRenderer() 
}, { 
    id : 'cess', 
    header : "Cess", 
    dataIndex : 'cess', 
    width : 80, 
    align : 'right', 
    selectOnFocus : true, 
    editor : new Ext.form.NumberField({}), 
    renderer : Gts.payItemRenderer() 
}, { 
    id : 'totalTax', 
    header : "Total Tax", 
    dataIndex : 'totalTax', 
    width : 80, 
    align : 'right', 
    selectOnFocus : true, 
    editor : new Ext.form.NumberField({}), 
    renderer : Gts.payItemRenderer() 
}, { 
    id : 'taxAmount', 
    header : "Taxable Income", 
    dataIndex : 'taxAmount', 
    width : 100, 
    align : 'right', 
    selectOnFocus : true, 
    editor : new Ext.form.NumberField({}), 
    renderer : Gts.payItemRenderer() 
}, { 
    id : 'remarks', 
    header : "Remarks", 
    dataIndex : 'remarks', 
    width : 250, 
    editor : new Ext.form.TextField({}) 
}, { 
    id : 'modifiedDate', 
    header : "Modified On", 
    dataIndex : 'modifiedDate', 
    width : 100, 
    renderer : Ext.util.Format.dateRenderer('d M Y h:i:s A'), 
    width : 150 
} 

]); 

this.itoGrid = new Ext.grid.EditorGridPanel({ 
    store : this.itoStore, 
    cm : incomeTaxOverrideModel, 
    autoExpandColumn : 'remarks', 
    autoScroll : true, 
    containerScroll : true, 
    frame : false, 
    stripeRows : true, 
    width : 830, 
    height : 233, 
    clicksToEdit : 1, 
    layout : 'fit', 
    loadMask : true, 
    tbar : [this.addAction, this.deleteAction], 
    trackMouseOver : true 
}); 

我的方法

calculateTaxForword :function(){ 
    console.log(this.itoGrid) 
    //console.log(this.itoGrid.getStore().getModifiedRecords()) 
} 

創建,但其不來anything.i有基於原始tax.surcharge和塞斯計算值,所以我需要在我method.how所有值做這個任何一個請幫助

回答

5

CellEditing插件有一個beforeedit事件,你可以聽: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.plugin.CellEditing-event-beforeedit

這會給你訪問像:

Parameters 
editor : Ext.grid.plugin.CellEditing 
e : Object 
An edit event with the following properties: 

grid - The grid 
record - The record being edited 
field - The field name being edited 
value - The value for the field being edited. 
row - The grid table row 
column - The grid Column defining the column that is being edited. 
rowIdx - The row index that is being edited 
colIdx - The column index that is being edited 
cancel - Set this to true to cancel the edit or return false from your handler. 
eOpts : Object - The options object passed to Ext.util.Observable.addListener. 
相關問題