Results 1 to 3 of 3

Thread: Creating a simple mixin for a grid panel

  1. #1
    Sencha Premium Member
    Join Date
    May 2011
    Posts
    167

    Default Creating a simple mixin for a grid panel

    Hello,

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

    Code:
    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);
    
    }
    });

    Code:
    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.

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256
    Answers
    759

    Default

    Renderer expects a function reference, apply() calls it immediately.

    Instead, you want:

    Code:
    newCol.scope = me;
    newCol.renderer = this.columnRenderer.colRenderer;
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Sencha Premium Member
    Join Date
    May 2011
    Posts
    167

    Default

    Im still getting this error

    Code:
     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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •