Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8213033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:58:39+00:00 2026-06-07T10:58:39+00:00

I’ve got an ExtJS (4.0.7) GridPanel that I’m populating from a store. The values

  • 0

I’ve got an ExtJS (4.0.7) GridPanel that I’m populating from a store. The values that I display in the GridPanel’s column need to have a different view depending on the type of data that’s in the record.

The ultimate goal is that records with “double” or “integer” value for the record’s type property present a slider to the user that they can adjust, and a type of “string” just renders some read-only text.

I’ve created a custom Column to do this. It inspects the type in the renderer and determines what to render.

I’ve got the “string” working fine with the code below, but struggling with how I can dynamically create and render the more complicated slider control in the column.

This simplified example is just trying to render a Panel with a date control in it as if I can get that going, I can figure out the rest of the slider stuff.

Ext.define('MyApp.view.MyColumn', {
    extend: 'Ext.grid.column.Column',
    alias: ['widget.mycolumn'],

    stringTemplate: new Ext.XTemplate('code to render {name} for string items'),

    constructor: function(cfg){
        var me = this;
        me.callParent(arguments);

        me.renderer = function(value, p, record) {
            var data = Ext.apply({}, record.data, record.getAssociatedData());

            if (data.type == "string") {
                return me.renderStringFilter(data);
            } else if (data.type == "double" || data.type == "integer") {
                return me.renderNumericFilter(data);
            } else {
                log("Unknown data.type", data);

        };
    },

    renderStringFilter: function(data) {
        // this works great and does what I want
        return this.stringTemplate.apply(data);
    },

    renderNumericFilter: function(data) {

        // ***** How do I get a component I "create" to render 
        // ***** in it's appropriate position in the gridpanel?
        // what I really want here is a slider with full behavior
        // this is a placeholder for just trying to "create" something to render

        var filterPanel = Ext.create('Ext.panel.Panel', {
            title: 'Filters',
            items: [{
                xtype: 'datefield',
                fieldLabel: 'date'
            }],
            renderTo: Ext.getBody() // this doesn't work
        });
        return filterPanel.html;  // this doesn't work
    }
});

My problem really is, how can I Ext.create a component, and have it render into a column in the gridpanel?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:58:40+00:00Added an answer on June 7, 2026 at 10:58 am

    There are a few ways that I have seen this accomplished. Since the grid column is not an Ext container it can not have Ext components as children as part of any configuration the way other container components can. Post grid-rendering logic is required to add Ext components to cells.

    This solution modifies your custom column render so that it puts a special css class on the rendered TD tag. After the grid view is ready, the records are traversed and the custom class is found for appropriate special columns. A slider is rendered to each column found.

    The code below is a modified version of the ext js array grid example provided in the Sencha examples. The modification mixes in the custom column renderer and the post grid rendering of sliders to TD elements.

    This example only includes enough modification of the Sencha example to show the implementation ideas. It lacks separated view and controller logic.

    This is modified from here

     Ext.require([
         'Ext.grid.*',
         'Ext.data.*',
         'Ext.util.*',
         'Ext.data.Model'
     ]);
    
    
     Ext.onReady(function() {
    
         // sample static data for the store
         Ext.define('Company', {
             extend: 'Ext.data.Model',
             fields: ['name', 'price', 'change', 'pctChange', 'lastUpdated', 'type']
         });
    
         var myData = [
             ['3m Co', 71.72, 2, 0.03, '9/1/2011', 'integer'],
             ['Alcoa Inc', 29.01, 4, 1.47, '9/1/2011', 'string'],
             ['Altria Group Inc', 83.81, 6, 0.34, '9/1/2011', 'string'],
             ['American Express Company', 52.55, 8, 0.02, '9/1/2011', 'string'],
             ['American International Group, Inc.', 64.13, 2, 0.49, '9/1/2011', 'integer'],
             ['AT&T Inc.', 31.61, 4, -1.54, '9/1/2011', 'integer'],
             ['Boeing Co.', 75.43, 6, 0.71, '9/1/2011', 'string'],
             ['Caterpillar Inc.', 67.27, 8, 1.39, '9/1/2011', 'integer'],
             ['Citigroup, Inc.', 49.37, 1, 0.04, '9/1/2011', 'integer'],
             ['E.I. du Pont de Nemours and Company', 40.48, 3, 1.28, '9/1/2011', 'integer'],
             ['Exxon Mobil Corp', 68.1, 0, -0.64, '9/1/2011', 'integer'],
             ['General Electric Company', 34.14, 7, -0.23, '9/1/2011', 'integer']
         ];
    
         // create the data store
         var store = Ext.create('Ext.data.ArrayStore', {
             model: 'Company',
             data: myData
         });
    
         // existing template
         stringTemplate = new Ext.XTemplate('code to render {name} for string items');
    
         // custom column renderer
         specialRender = function(value, metadata, record) {
             var data;
    
             data = Ext.apply({}, record.data, record.getAssociatedData());
    
             if (data.type == "string") {
                 return stringTemplate.apply(data);;
             } else if (data.type == "double" || data.type == "integer") {
                 // add a css selector to the td html class attribute we can use it after grid is ready to render the slider
                 metadata.tdCls = metadata.tdCls + 'slider-target';
                 return '';
             } else {
                 return ("Unknown data.type");
    
             }
         };
    
         // create the Grid
         grid = Ext.create('Ext.grid.Panel', {
             rowsWithSliders: {},
             store: store,
             stateful: true,
             stateId: 'stateGrid',
             columns: [{
                 text: 'Company',
                 flex: 1,
                 sortable: false,
                 dataIndex: 'name'
             }, {
                 text: 'Price',
                 width: 75,
                 sortable: true,
                 renderer: 'usMoney',
                 dataIndex: 'price'
             }, {
                 text: 'Change',
                 width: 75,
                 sortable: true,
                 dataIndex: 'change',
                 renderer: specialRender,
                 width: 200
             }, {
                 text: '% Change',
                 width: 75,
                 sortable: true,
                 dataIndex: 'pctChange'
             }, {
                 text: 'Last Updated',
                 width: 85,
                 sortable: true,
                 renderer: Ext.util.Format.dateRenderer('m/d/Y'),
                 dataIndex: 'lastUpdated'
             }],
             height: 350,
             width: 600,
             title: 'Irm Grid Example',
             renderTo: 'grid-example',
             viewConfig: {
                 stripeRows: true
             }
         });
    
         /**
          * when the grid view is ready this method will find slider columns and render the slider to them
          */
         onGridViewReady = function() {
             var recordIdx,
                 colVal,
                 colEl;
    
             for (recordIdx = 0; recordIdx < grid.store.getCount(); recordIdx++) {
                 record = grid.store.getAt(recordIdx);
                 sliderHolder = Ext.DomQuery.select('.slider-target', grid.view.getNode(recordIdx));
                 if (sliderHolder.length) {
                     colEl = sliderHolder[0];
    
                     // remove div generated by grid template - alternative is to use a new template in the col
                     colEl.innerHTML = '';
    
                     // get the value to be used in the slider from the record and column
                     colVal = record.get('change');
    
                     // render the slider - pass in the full record in case record data may be needed by change handlers
                     renderNumericFilter(colEl, colVal, record)
                 }
             }
    
         }
    
         // when the grids view is ready, render sliders to it
         grid.on('viewready', onGridViewReady, this);
    
         // modification of existing method but removed from custom column 
         renderNumericFilter = function(el, val, record) {
    
             var filterPanel = Ext.widget('slider', {
                 width: 200,
                 value: val,
                 record: record,
                 minValue: 0,
                 maxValue: 10,
                 renderTo: el
             });
    
         }
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view passing on information from a database: def serve_article(request, id): served_article
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.