Results 1 to 4 of 4

Thread: Passing config parameters in renderer

  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    19
    Vote Rating
    0
      0  

    Default Unanswered: Passing config parameters in renderer

    Hi,
    I am setting config parameters(driverTypeLookup, dataLookupValue) as shown in below code -
    --------------------------------------------------------------------------------
    actualColumns.push({header: columns[i].headerText, dataIndex: columns[i].dataLookupValue, xtype:'ewcolumn',
    driverTypeLookup:columns[i].driverTypeLookup,
    dataLookupValue:columns[i].dataLookupValue});
    --------------------------------------------------------------------------------
    I want to use these parameters (driverTypeLookup,dataLookupValue) in renderer of ewcolumn.

    In ewcolumn class initComponent method, I am trying set config for tht class -
    --------------------------------------------------------------------------------
    initComponent: function() {
    var config = {
    driverTypeLookup1:this.driverTypeLookup
    };
    Ext.apply(this, Ext.apply(this.initialConfig, config));
    this.callParent(arguments);
    console.log(" initComponent"+this.driverTypeLookup1);
    },
    --------------------------------------------------------------------------------
    Is this correct way to set config variables?

    Then I try to access this variable in renderer, it says 'undefined'
    renderer : function(value, metaData, record, rowIndex, colIndex,store, view)
    {
    console.log(" in renderer"+this.driverTypeLookup1);
    }


    Can you please guide, how I can send some information to renderer ? Is config parameters correct solution. If yes, then how should I pass it?

    Thanks

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,388
    Answers
    716
    Vote Rating
    499
      0  

    Default

    Parameters are already there.. simply explore each in the console:

    console.log('metaData>>'+metaData);
    console.log('record>>'+record);
    ..

    What are you trying to achieve?

    Regards,
    Scott.

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    19
    Vote Rating
    0
      0  

    Default

    Hi Scott,
    I have a requirement to show images / icons in grid cell as per some data values.
    Also we have created custom column class to make all logic separate, so it can be reused for other such requirements.

    Now, My prob was, the 'crieteria data' was not accessible into 'custom column class' directly. So I wanted to pass it to renderer using some variables/parameters.

    I have achieved it somehow.

    Base class -
    this.driverTypeLookup=[];
    this.columnType=[];

    for (var i=0; i< columns.length; i++){
    this.driverTypeLookup[i]=columns[i].driverTypeLookup;
    this.columnType[i]=columns[i].columnType;

    actualColumns.push({header: columns[i].headerText, dataIndex: columns[i].dataLookupValue, xtype:'ewcolumn'
    });
    }


    custom column class, where image selection logic is (ewcolumn) -

    renderer: function(value, metaData, record, rowIndex, colIndex,store, view)
    {
    var columnType = this.columnType[colIndex];
    var driverType = record.raw[this.driverTypeLookup[colIndex]];
    }


    Thank you for your help!

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,388
    Answers
    716
    Vote Rating
    499
      0  

    Default

    I have a requirement to show images / icons in grid cell as per some data values.
    Quick note .. have you tried using an actionColumn to display custom icons in the cells?

    Code:
    getClass: function(v, meta, rec) {          // Or return a class from a function
        if (rec.get('change') < 0) {
            this.items[1].tooltip = 'Hold stock';
            return 'alert-col'; // CSS rule
        } else {
            this.items[1].tooltip = 'Buy stock';
            return 'buy-col';
        }
    },

    Scott.

Tags for this Thread

Posting Permissions

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