View Full Version : [SOLVED] How to get selectionModel of extended Ext.grid.GridPanel

13 Aug 2009, 7:47 AM
SOLVED: Needed to add 'scope: this,' to tbar item.

The following is an extended GridPanel which is opened inside a TabPanel inside a Viewport. Everything works as intended with paging, sorting, etc. I need to access the grid's selectionModel on calls to the grid's tbar buttons, how do I do this? this.getSelectionModel() does not work.

// declare namespace

// constructor, accept config or references to other elements as parameters if needed
App.Panels.ItemPanel = function(){

this.store = new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields: ['id', 'code', 'description'],
idProperty: 'id',
totalProperty: 'results',
root: 'rows'
proxy: new Ext.data.HttpProxy({
url: 'http://localhost/index.php',
method: 'POST'
autoLoad: true,
remoteSort: true,
sortInfo: {
field: 'code',
direction: 'ASC'

// call superclass constructor with config
App.Panels.ItemPanel.superclass.constructor.call(this, {
id: 'manage-items',
title: 'Item Management',
iconCls: 'icon-items',
closable: true,
stripeRows: true,
store: this.store,
autoExpandColumn: 'description',
loadMask: 'Loading...',
columns: [
{header: 'Code', dataIndex: 'code', id: 'code', sortable: true},
{header: 'Description', dataIndex: 'description', id: 'description'}
sm: new Ext.grid.RowSelectionModel({
singleSelect: true
tbar: [{
text: 'New',
iconCls: 'icon-new',
handler: this.newItem
text: 'Edit',
iconCls: 'icon-edit',
handler: this.editItem
text: 'Delete',
iconCls: 'icon-delete',
handler: this.deleteItem
bbar: new Ext.PagingToolbar({
pageSize: 10,
store: this.store
}); // e/o superclass constructor

*********** DO I NEED TO ATTACH LISTENER HERE? ***********
// attach listeners to events
this.on('xyzevent', this.onXyzEvent, this);

}; // e/o constructor

// call Ext.extend
// Ext.extend(subclass, superclass, overrides);
Ext.extend(Ratexpress.Panels.CommodityPanel, Ext.grid.GridPanel, {

/******** ISSUES HERE *********/
newItem : function(b, e){
/******** Need to access selectionModel here. this.getSelectionModel() does not work **********/

}); // e/o Ext.extend

// register xtype with Ext
Ext.reg('itemPanel', App.Panels.ItemPanel);