PDA

View Full Version : Creating a simple mixin for a grid panel



pscanlon1
15 Jul 2013, 6:09 AM
Hello,

Im just trying to create a couple mixins for a grid panel, to seperate out my code into easier to read sections.


Ext.define('My.Custom.Grid',{
extends:'Ext.grid.Panel',
alias:'widget.customGrid',
mixins:{
columnRenderer:'My.Custom.ColumnRenderer'
},
initComponent:{
var me=this,
columns=[];

var newCol={
dataIndex:'firstColumn'
}
newCol.renderer=this.columnRenderer.colRenderer.apply(undefined,arguments);


Ext.apply(me,{
columns:columns
});
me.callParent(arguments);

}
});



Ext.define('My.Custom.ColumnRenderer',{

colRenderer:function(value, metaData, record, rowIndex, colIndex, store, view) {
return value*100;
}
);


My code is getting the error in ExtClass.registerPreprocessor, Cannot read property Instance of undefined.

What am I doing wrong? The main goal is to seperate out a bunch of functionality, primarily because its too much in one file.

Thanks.

evant
15 Jul 2013, 5:54 PM
Renderer expects a function reference, apply() calls it immediately.

Instead, you want:



newCol.scope = me;
newCol.renderer = this.columnRenderer.colRenderer;

pscanlon1
16 Jul 2013, 8:49 AM
Im still getting this error


if (!Parent.$isClass) {
for (i in basePrototype) {
if (!parentPrototype[i]) {
parentPrototype[i] = basePrototype[i];
}
}
}


parentPrototype is undefined? this happens whether I add it to Requires or mixins