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

  • Home
  • SEARCH
  • 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 8250097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:46:30+00:00 2026-06-07T23:46:30+00:00

I am trying to write a generic panel component with a search text field,

  • 0

I am trying to write a generic panel component with a search text field, a search button and a grid displaying the results. What I am aiming for is a generic component and you can create different instances of it with more or less columns, different column titles and different search logic.

I have created ExtJS4 code with Sencha Architect 2 where this stuff looks as follows:

initComponent: function() {
    var me = this;

    Ext.applyIf(me, {
        items: [
            {
                xtype: 'textfield',
                itemId: 'txtObjSearch',
                fieldLabel: 'Search for'
            },
            {
                xtype: 'button',
                itemId: 'btnSearch',
                icon: '/rhidmoplus/icons/zoom.png',
                text: 'Search'
            },
            {
                xtype: 'gridpanel',
                itemId: 'gridResultObjects',
                title: '',
                store: 'testStore',
                colspan: 2,
                columns: [
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'MSKEYVALUE',
                        text: 'ID'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'DISPLAYNAME',
                        text: 'Displayname'
                    }
                ],
                viewConfig: {
                    itemId: 'gridView'
                }
            }
        ]
    });

    me.callParent(arguments);
},

The store and the 2 columns are only dummies. I want to provide the real store and the real column configuration in the constructor of the custom component. I found the GridPanel.reconfigure (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.Panel-method-reconfigure) method which seemed to perfectly fit my needs.
However, the following code yields an error:

    ////////////////////////
    // Prepare store
    ////////////////////////

    // prepare fields and columns
    var __fields = [];
    var __columns = [];

    for (var jj=0; jj<config.columns.length; jj++) {
        var item2 = {};
        var item = [];
        // for fields
        item.name = config.columns[jj].title;
        __fields.push (item);
        // for columns
        item2.xtype = 'gridcolumn';
        item2.dataIndex = config.columns [jj].dataIndex;
        item2.text = config.columns [jj].title;
        __columns.push (item2);    
    }

    console.debug ('columns.length = ' + __columns.length + ', fields.length = ' + __fields.length);

    var sm = new Ext.selection.RowModel();
    //sm.bindComponent (grid.getView ());

    var __store = Ext.create ('Ext.data.Store', {
        storeId: config.storeId,
        fields: __fields,
        selModel: sm,
        proxy: {
            type: 'ajax',
            url: '/rhidmo/rest/ktec_js_searchUtils',
            reader: {
                type: 'json',
                root: 'entries'
            }
        }
    });

    grid.reconfigure (__store, __columns);

which is:

Uncaught TypeError: Cannot read property ‘length’ of undefined

in the method onLastFocusChanged of the selection model. If I pass null as first argument of reconfigure then this doesn’t happen but I would like to dynamically create a store (otherwise each instance of my component uses the same store which is certainly not good).

Maybe my configuration of the store is not correct but I copied it from the code Sencha Architect creates, so it can’t be that wrong.

Thanks for any hint.
Cheers
Kai

========================================

Hi, now changed the code:

// prepare fields and columns
var __fields = [];
var __columns = [];

for (var jj=0; jj<config.columns.length; jj++) {
    var item2 = Ext.create ('Ext.grid.column.Column', {
        dataIndex: config.columns [jj].dataIndex,
        text: config.columns [jj].title
    });
    var item = Ext.create ('Ext.data.Field', {
        name: config.columns[jj].title
    });
    __fields.push (item);
   __columns.push (item2);    
}

and I still get the same error:

Uncaught TypeError: Cannot read property 'length' of undefined
Ext.define.onLastFocusChangedext-all-debug.js:89284
Ext.define.setLastFocusedext-all-debug.js:59431
Ext.define.clearSelectionsext-all-debug.js:59543
Ext.define.refreshext-all-debug.js:59523
Ext.define.bindext-all-debug.js:59143
Ext.define.bindStoreext-all-debug.js:60584
Ext.define.bindStoreext-all-debug.js:78007
Ext.define.reconfigureext-all-debug.js:78033
Ext.define.configureGenericSearchPanel.js:141
Ext.define.onStoreTestPanelRenderMainController.js:471
fireext-all-debug.js:10658
  • 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-07T23:46:32+00:00Added an answer on June 7, 2026 at 11:46 pm

    I’ve fixed it. I was trying to do this in the render event. After that didn’t work, I added a button to the page and called reconfigure in the button click handler. That worked fine.
    This led me to try the afterrender event, which does the trick.

    Thanks for your help,

    Cheers
    Kai

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a generic method that can be used to deserialize xml
I am trying to write a generic method that will search a file for
I'm trying to write generic code that can lex any stream of characters (
I am trying to write a generic method that would bind any asp.net UI
I'm trying to write a generic function that works with JSON arrays containing arbitrary
I'm trying to write a generic class which contains a generic TObjectList< T >
I'm trying to write a generic XML to Core Data parser using libxml2. Since
I am trying to write a generic module to extend the World class. I
I am trying to write some generic LINQ queries for my entities, but am
As an experiment I'm trying to write a generic MVP framework. I started with:

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.