PDA

View Full Version : Ext RelayEvents Problem



xxtommoxx
27 Dec 2010, 12:29 PM
Hello I have an editable grid and I would like to relay the events of one column 'header' to another. Specifically if i modify the date of a row in the grid it will change the textfield of that row to some value. I used custom events but do not know how to call it within the grid to relay the events.




MyDateField = Ext.extend(Ext.form.DateField, {

format: 'm/d/Y',
initComponent: function()
{
MyDateField.superclass.initComponent.call(this);
this.on('select',function() {
this.fireEvent('dateChanged');
});


}

});

// Text Field
MyTextField= Ext.extend(Ext.form.TextField, {
name: 'default',
initComponent: function() {
MyTextField.superclass.initComponent.call(this);

// Add a listener for dateChanged event
this.on('dateChanged',
function(a, b) {
// call my method when dateChanged event is fired
this.setValue("Event Triggered");
console.log("IT WORKS");
});


}
});

var grid = new Ext.grid.GridPanel({
store: store,
bbar: pagingToolbar,
columns: [
{header: "Name",
width: 100,
sortable: true,
dataIndex: 'name',
editor: new MyTextField()},
{header: "Short Date",
width: 100,
sortable: true,
dataIndex: 'shortDate',
renderer: Ext.util.Format.dateRenderer('m/d/Y'),
editor: new MyDateField()}
],
plugins: editor,
title: 'Test',
height: 300,
width:680,
frame:true,
});




I know that you can relay events by doing this



var mdf = new MyDateField();
var mtf = new MyTextField();
mtf.relayEvents(mdf,['dateChanged']);
My question is how do I call this within the gridpanel ? Thanks

Condor
28 Dec 2010, 1:17 AM
This is wrong. You don't want to relay data between editors!

You want to update another field in the current record when selecting an item in the combobox editor.

You could use the grid afteredit event for that.