title: Assign dynamic tpl to combo in grid
body: <p>I have a grid in that one column has editor of type combo. This combo fills dynamically. Right now i can show only one column in its drop down list but i want to show more than one column in its drop down list. each drop down list may contain different column names.</p>
  
  <p>I succeed in creating tpl string but fail to assign this tpl to combo.</p>
  
  <p>My logic is:</p>
  
  <ol>
  <li>create grid</li>
  <li>in focus event- fill combo dynamically and create tpl</li>
  <li>assign tpl to combo</li>
  <li>show drop down list by expand method.</li>
  </ol>
  
  <p>Please suggest me if there is any method like combo.setTpl(tpl_string)</p>
  
  <p>Logic Description:</p>
  
  <h2>1. Created model which will hold two columns</h2>
  
  <pre><code>i. column_name: Name of column from data base.
  ii. data_type: Data type of column
  
  Ext.define('modelTableStructure',
  {
      extend: 'Ext.data.Model',
      fields:
      [
          { name: 'column_name', type: 'string' },
          { name: 'data_type', type: 'string' }
      ]
  });
  </code></pre>
  
  <h2>2. Created store which will use model in step 1</h2>
  
  <pre><code>  var storeTableStructure = Ext.create('Ext.data.Store',
    {
      model: 'modelTableStructure',
      autoLoad: false,
      proxy: new Ext.data.HttpProxy
      ({
          type: 'ajax',
          reader:
          {
              type: 'json',
              root: 'rows',
              idProperty: 'column_name'
           }// reader end
      }), // proxy end
          listeners:
      {
          load: onLoadStore
      }
  
  });
  </code></pre>
  
  <h2>3. This is to change data type of columns as per EXT JS</h2>
  
  <pre><code>var type_lookup = new Object;
  type_lookup['int'] = 'numberfield';
  type_lookup['float'] = 'numberfield';
  type_lookup['string'] = 'textfield';
  type_lookup['date'] = 'datefield';
  type_lookup['boolean'] = 'checkbox';
  type_lookup['varchar'] = 'textfield';
  type_lookup['bit'] = 'checkbox';
  </code></pre>
  
  <h2>4. This is a model and store of a combo</h2>
  
  <pre><code>Ext.define('modelTableData',
  {
      extend: 'Ext.data.Model'
  });
  
  var storeDataID = new Ext.data.JsonStore
  ({
      model: 'modelTableData',
      autoLoad: false,
      proxy: new Ext.data.HttpProxy
      ({
          type: 'ajax',
          url: 'url to get data',
          reader:
          {
              type: 'json',
              root: 'rows',
              idProperty: 'primary key column name'
           }
          }) 
  });
  </code></pre>
  
  <h2>5. Here is the method which will get called on store load which we created in step 2</h2>
  
  <pre><code>function onLoadStore() {
  var cnt = storeTableStructure.getCount();
  fields = [];
  var colNames = [];
  for (var i = 0; i &lt; cnt; i++) {
      var Col_nm = storeTableStructure.getAt(i).data.column_name;
      var Col_Type = storeTableStructure.getAt(i).data.data_type;
      colNames[i] = Col_nm;
      fields[i] = {
          name: Col_nm,
          type: Col_Type,
          editor:
          {
              xtype: type_lookup[Col_Type]
          }
      };
  }
  DataID_createHeaderTPL(colNames);
  modelTableData.setFields(fields, 'COL_PK_ID', 'COL_PK_ID');
  var proxy = new Ext.data.HttpProxy
  ({
      type: 'ajax',
      url: 'TestCase.ashx?methodname=getdataids&amp;stepdisplayname=name',
      reader:
      {
          type: 'json',
          root: 'rows',
          idProperty: 'COL_PK_ID'
      }// reader end
   });  // proxy end
  
  proxy.setModel(modelTableData, true)
  storeDataID.setProxy(proxy);
  storeDataID.load({
      url: 'TestCase.ashx?methodname=getdataids&amp;stepdisplayname=name'
  });
  };
  
  var tplDataid = '';
  
  function DataID_createHeaderTPL(colNames) {
  var hd = '';
  var td = '';
  for (var i_f = 0; i_f &lt; colNames.length; i_f++) {
      hd = hd + '&lt;th width=100&gt; ' + colNames[i_f] + ' &lt;/th&gt;';
      td = td + '&lt;td width=100&gt; {' + colNames[i_f] + '} &lt;/td&gt;';
  }
  
  tplDataid = '&lt;tpl&gt;' +
              '&lt;table width=500&gt;' +
                      '&lt;tr style="text-align: left;"&gt;' +
                          hd +
                      '&lt;/tr&gt;' +
                  '&lt;/table&gt;' +
              '&lt;/tpl&gt;' +
              '&lt;tpl for="."&gt;' +
                  '&lt;div class="x-boundlist-item"&gt;' +
                      '&lt;table width=500&gt;' +
                          '&lt;tr&gt;' +
                              td +
                          '&lt;/tr&gt;' +
                      '&lt;/table&gt;' +
                  '&lt;/div&gt;' +
              '&lt;/tpl&gt;';
  }
  </code></pre>
  
  <h2>6. This function is creating my grid.</h2>
  
  <pre><code>function showRecordDetails() {
  storeTableStructure.load({
      url: 'TestCase.ashx?methodname=gettablestructure&amp;stepdisplayname=name'
  });
  
      Ext.define('gridTCStep',
  {
      extend: 'Ext.grid.Panel',
      alias: 'widget.gridTCStep',
  
      requires:
      [
          'Ext.grid.plugin.CellEditing',
          'Ext.form.field.Text',
          'Ext.toolbar.TextItem'
      ],
      initComponent: function() {
          this.editing = Ext.create('Ext.grid.plugin.CellEditing', {
              clicksToEdit: 1
          });
          Ext.apply(this,
          {
              store: StoreTCStep,
              width: 980,
              height: 340,
              plugins: [this.editing],
              columns:
              [
                  {
                      id: "DATA_ID",
                      header: "Data ID",
                      minWidth: 50,
                      dataIndex: 'DATA_ID',
                      flex: 3,
                      editor:
                      {
                          xtype: 'combo',
                          allowBlank: false,
                          forceSelection: true,
                          store: storeDataID,
                          hideTrigger: true,
                          displayField: 'Data_ID',
                          valueField: 'Data_ID',
                          enableKeyEvents: true,
                          matchFieldWidth: false,
                          listeners:
                          {
                              'focus': DataID_Focus,
                              'keypress': combo_KeyPress
                          },
                          tpl: Ext.create('Ext.XTemplate', tplDataid),
                          displayTpl: Ext.create('Ext.XTemplate',
                              '&lt;tpl for="."&gt;',
                                  '{Data_ID}',
                              '&lt;/tpl&gt;'
                          )
                      }
                  }
              ]
          }); // EXT.APPLY
          this.callParent();
      } //in it component
  }); // gridTCStep end
  
      button = Ext.get('btnNewEntry');
      var lblWd = 90;
  
      var formPanel = new Ext.form.FormPanel
  ({
      bodyStyle: 'padding:5px 5px 5px 5px',
      submitEmptyText: true,
      items:
      [
          {
              xtype: 'panel',
              name: 'gridpanel',
              shadow: false,
              items:
                  [
                      {
                          id: 'griddata',
                          items: gridTCStep,
                          store: StoreTCStep
                      }
                  ]
          }
      ]// items
  
  });       // form panel end
  
      win = Ext.create('widget.window',
      {
          closable: true,
          frame: false,
          closeAction: 'destroy',
          width: 1000,
          minWidth: 350,
          height: 600,
          shadow: false,
          resizable: false,
          draggable: false,
          items:
          [
              {
                  id: 'westpanel',
                  name: 'westpanel',
                  items: formPanel
              }
          ]// items of window
      }); // Window creation
  
  
      win.show();          // win.show end
  
  }; // function end
  </code></pre>
  
  <h2>7. On focus event of combo i am calling this function. In this function i loaded store created in step 2. so that combo will filled by new record and as per new records it will have multiple columns. You can see tpl is created in store load event.</h2>
  
  <pre><code>   function DataID_Focus(combo, records, eOpts) {
      storeTableStructure.load({
          url: 'TestCase.ashx?methodname=gettablestructure&amp;stepdisplayname=name'
      });
  
      combo.tpl = Ext.create('Ext.XTemplate', tplDataid);
      combo.expand();
     };
  </code></pre>