select first row in the onShow event

This commit is contained in:
Damien Churchill 2009-04-07 22:07:27 +00:00
parent c93a3b4680
commit 891b1120a3
1 changed files with 56 additions and 52 deletions

View File

@ -22,29 +22,27 @@ Copyright:
*/ */
(function() { (function() {
PreferencesWindow = Ext.extend(Ext.Window, { PreferencesWindow = function(config) {
layout: 'border', Ext.apply(this, config);
width: 450, this.layout = 'border';
height: 450, this.width = 450;
buttonAlign: 'right', this.height = 450;
closeAction: 'hide', this.buttonAlign = 'right';
closable: true, this.closeAction = 'hide';
iconCls: 'x-deluge-preferences', this.closable = true;
plain: true, this.iconCls = 'x-deluge-preferences';
resizable: false, this.plain = true;
title: _('Preferences'), this.resizable = false;
buttons: [{ this.title = _('Preferences');
this.buttons = [{
text: _('Close') text: _('Close')
},{ },{
text: _('Apply') text: _('Apply')
},{ },{
text: _('Ok') text: _('Ok')
}], }];
this.currentPage = false;
initComponent: function() { this.items = [{
PreferencesWindow.superclass.initComponent.call(this);
this.categoriesGrid = this.add({
xtype: 'grid', xtype: 'grid',
region: 'west', region: 'west',
title: _('Categories'), title: _('Categories'),
@ -52,51 +50,57 @@ Copyright:
fields: [{name: 'name', mapping: 0}] fields: [{name: 'name', mapping: 0}]
}), }),
columns: [{id: 'name', renderer: fplain, dataIndex: 'name'}], columns: [{id: 'name', renderer: fplain, dataIndex: 'name'}],
/*selModel: new Ext.grid.RowSelectionModel({ sm: new Ext.grid.RowSelectionModel({
singleSelect: true, singleSelect: true,
listeners: {'rowselect': {fn: this.onPageSelect, scope: this}} listeners: {'rowselect': {fn: this.onPageSelect, scope: this}}
}),*/ }),
hideHeaders: true, hideHeaders: true,
autoExpandColumn: 'name', autoExpandColumn: 'name',
deferredRender: false,
autoScroll: true,
margins: '5 0 5 5', margins: '5 0 5 5',
cmargins: '5 0 5 5', cmargins: '5 0 5 5',
width: 120, width: 120,
collapsible: true collapsible: true
}); }, {
this.configPanel = this.add({
region: 'center', region: 'center',
title: 'Test', title: 'Test',
margins: '5 5 5 5', margins: '5 5 5 5',
cmargins: '5 5 5 5' cmargins: '5 5 5 5'
}); }];
PreferencesWindow.superclass.constructor.call(this);
};
this.currentPage = null; Ext.extend(PreferencesWindow, Ext.Window, {
initComponent: function() {
PreferencesWindow.superclass.initComponent.call(this);
this.categoriesGrid = this.items.get(0);
this.configPanel = this.items.get(1);
this.on('show', this.onShow.bindWithEvent(this));
}, },
addPage: function(name, page) { addPage: function(name, page) {
var store = this.categoriesGrid.getStore(); var store = this.categoriesGrid.getStore();
store.loadData([[name]], true); store.loadData([[name]], true);
if (this.currentPage == null) {
this.configPanel.setTitle(name);
this.currentPage = 0;
}
}, },
onPageSelect: function(selModel, rowIndex, r) { onPageSelect: function(selModel, rowIndex, r) {
this.currentPage = rowIndex;
this.configPanel.setTitle(r.get('name')); this.configPanel.setTitle(r.get('name'));
}, },
onRender: function(ct, position) { onShow: function() {
PreferencesWindow.superclass.onRender.call(this, ct, position); if (!this.categoriesGrid.getSelectionModel().hasSelection()) {
//this.categoriesGrid.getSelectionModel().selectFirstRow(); this.categoriesGrid.getSelectionModel().selectFirstRow();
}
} }
}); });
Deluge.Preferences = new PreferencesWindow(); Deluge.Preferences = new PreferencesWindow();
})(); })();
Deluge.Preferences.addPage('Downloads', {}); Deluge.Preferences.addPage('Downloads', {
});
Deluge.Preferences.addPage('Network', {}); Deluge.Preferences.addPage('Network', {});
Deluge.Preferences.addPage('Bandwidth', {}); Deluge.Preferences.addPage('Bandwidth', {});
Deluge.Preferences.addPage('Interface', {}); Deluge.Preferences.addPage('Interface', {});