PDA

View Full Version : How to override a function in extjs 3.0



freechoice
7 Jun 2009, 9:26 PM
In the examples,there's a example called writter

and in the UserGrid.js there a function like this

onAdd : function(btn, ev) {
var u = new this.store.recordType({
id : '',
time_year: '',
time_week : '',
price: '',
});
this.stopEditing();
this.store.insert(0, u);
this.startEditing(0, 1);
},

If the column of the grid is trying to dynamic load, so we need to redefine the this.store.recordType content function

so i use
var modifystring = '{';
for(var i=0; i<index; i++) {

modifystring += columns.getAt(i).get('name') + ":" + '\'\',';
}
modifystring += '}';
App.user.Grid.onAdd = function(btn, ev) {
var u = new this.store.recordType(eval(modifystring));
this.stopEditing();
this.store.insert(0, u);
this.startEditing(0, 1);
};


but it dose not work

so any body who could tell me how to do that?