PDA

View Full Version : can't see Toolbar



tzander
10 Mar 2009, 7:19 AM
Hi,

I have a extentend grid:


RubrikGrid = Ext.extend(Ext.grid.GridPanel, {
loadMask : true,
initComponent : function() {
var RubrikFilters = new Ext.grid.GridFilters({
filters: [{
type: 'string'
}, {
type: 'string',
dataIndex: 'name'
}]
});

var RubrikStore = new Ext.data.JsonStore({
autoLoad : true,
url: '../services.php?class=RemRubrikService&method=listFilteredRubriken&filter=',
root: 'data',
totalProperty: 'totalCount',
id: 'id',
fields: [
'name','beschreibung', 'farbcode'
]
});


var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel([
sm, {
dataIndex: 'name',
header: 'Rubrik',
width: 170,
id: 'name'
}, {
header: "",
width: 17,
dataIndex:'farbcode',
cellActions:[{
iconIndex: 'farbcode'
}]
}
]);
var toolbar = new Ext.Toolbar( {
text: 'Alle',
handler: function(button , e) {
var grid = Ext.getCmp('rubrik_id');
grid.selModel.selectAll();
}
}, {
text: 'Keine',
handler: function(button , e) {
var grid = Ext.getCmp('rubrik_id');
grid.selModel.clearSelections();
}
}, {
text: 'markierte Rubriken',
id: 'delete_id',
disabled: true,
menu: [loeschen]
}, {
text: 'neue Rubrik',
handler: function() {
RubrikForm = Ext.getCmp('rubrik_form_id');
Ext.getCmp('detail_id').layout.setActiveItem('rubrik_form_id');
RubrikForm.doLayout();
RubrikForm.setTitle('neue Rubrik anlegen');
}
}
);
Ext.apply(this, {
bbar: toolbar,
autoScroll: true,
viewConfig: {
forceFit:true
},
cm: cm,
plugins:[RubrikFilters],
stripeRows: true,
split: true,
waitMsgTarget: true,
iconCls: 'grid',
store: RubrikStore,
border: false,
width: 340,
height: 230
}
);
RubrikGrid.superclass.initComponent.apply(this,arguments);
} // eo function initComponent
});
Ext.reg('rubrikgrid', RubrikGrid);


But I don't see the Toolbar even though my unit tests passes:


assertEquals('toolbar', grid.getBottomToolbar().getXType());

Thanks Torsten

mjlecomte
10 Mar 2009, 7:23 AM
looks ok at a glance, suggest you post working showcase using your extension:
http://extjs.com/learn/Ext_Forum_Help#Posting_a_working_showcase

Use local dummy data.

Animal
10 Mar 2009, 7:25 AM
Read your code



var toolbar = new Ext.Toolbar( {

text: 'Alle',

handler: function(button , e) {

var grid = Ext.getCmp('rubrik_id');

grid.selModel.selectAll();

}

}, {


That is not javascript.

10 Mar 2009, 7:36 AM
Read your code



var toolbar = new Ext.Toolbar( {

text: 'Alle',

handler: function(button , e) {

var grid = Ext.getCmp('rubrik_id');

grid.selModel.selectAll();

}

}, {


That is not javascript.

yeah it is . it's the same as:


new Ext.Toolbar( arg1, arg2,arg3)

or

new Ext.Toolbar({}, {},{})

10 Mar 2009, 7:36 AM
It's just not *valid* syntax for the toolbar.

Animal
10 Mar 2009, 7:39 AM
Ah yes, I see. I was thrown by the bad indenting.

tzander
10 Mar 2009, 7:41 AM
:s

thanks Animal

but why is the unit test running ?

mjlecomte
10 Mar 2009, 7:46 AM
Why don't you just set a breakpoint where the instance of toolbar is created. You should quickly find out why your config is wrong.

10 Mar 2009, 7:50 AM
Or how about reading the API or looking at examples? Toolbar expects an array of objects





var toolbar = new Ext.Toolbar( [{

text: 'Alle',

handler: function(button , e) {

var grid = Ext.getCmp('rubrik_id');

grid.selModel.selectAll();

}

}, ....... More objects .........]);

tzander
10 Mar 2009, 7:55 AM
yes thanks guys sorry for that. It is working now!

but still wondering why the unit test passed

mjlecomte
10 Mar 2009, 7:56 AM
Again, when all else fails, or even before that, set a break point and explore. I think about 3 clicks into stepping through the construction of that toolbar you'll see why it wouldn't work like you expected, and why it still created something.