Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EXTJS how to get the component without declare id?

Tags:

extjs

 Ext.define('MyApp.view.MyVehicleGridPanel', {
   extend: 'Ext.grid.Panel',
   alias: 'widget.mygrid',
   header: false,
   store: UserStore,
   multiSelect: false,
   columns: [
                {
                    xtype: 'gridcolumn',
                    dataIndex: '_id',

                    text: 'Vehicle ID'
                },
                {
                    xtype: 'gridcolumn',
                    width: 126,
                    dataIndex: 'Plat_No',
                    text: 'Plat Number'
                },
                {
                    xtype: 'gridcolumn',
                    width: 200,
                    dataIndex: 'Name',
                    text: 'Added By'
                }
            ]
})

i dont have any id declare in the gridpanel, because it will used in dynamicly,
so, i m using alias to find my grid component like below code

var grid = Ext.ComponentQuery.query('mygrid');
        console.log( Ext.ComponentQuery.query('mygrid') );
        if (grid.getSelectionModel().hasSelection()) { //error at here 
           var row = grid.getSelectionModel().getSelection()[0];
           console.log(row.get('Plat_No'));
        };      

But, firebug return error with TypeError: grid.getSelectionModel is not a function

any other way to find my gridpanel component?

like image 854
John Walker Avatar asked Feb 10 '14 11:02

John Walker


People also ask

What is ExtJS UI?

Ext js - Components - ExtJS UI is made up of one or many widgets called Components. Ext Js has various UI components defined that can be customized as per your requirements.

What happens when I remove the fluff from my ExtJS component?

Depending on your ExtJS version you may see other attributes, such as an ARIA role. When we discard the fluff we're left with something very simple: Let's add a few more options and some CSS so that we can actually see the component. The three settings we've added translate pretty directly into the markup for our component's element:

What is setheader in ExtJS?

setHeader updates the contents of the header. It is written in such a way that it could be called before or after the component is rendered. Even if you never have to write a low-level component like this, understanding the techniques it uses should help you to get a better grasp on the ExtJS source code.

What are some common misconceptions about ExtJS?

First let's tackle some common misconceptions. If you've spent a lot of time working with other frameworks then you might fall into the trap of viewing an ExtJS component as little more than an abstraction for manipulating a DOM element. In other words, the DOM is king.


1 Answers

Ext.ComponentQuery.query() returns an array of matched Components from within the passed root object.

So if you have only one mygrid component in your application, you can get your grid like this:

var grid = Ext.ComponentQuery.query('mygrid')[0];
like image 118
Akatum Avatar answered Nov 03 '22 02:11

Akatum