select first row in the onShow event
This commit is contained in:
parent
c93a3b4680
commit
891b1120a3
|
@ -22,81 +22,85 @@ 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;
|
||||||
|
this.items = [{
|
||||||
|
xtype: 'grid',
|
||||||
|
region: 'west',
|
||||||
|
title: _('Categories'),
|
||||||
|
store: new Ext.data.SimpleStore({
|
||||||
|
fields: [{name: 'name', mapping: 0}]
|
||||||
|
}),
|
||||||
|
columns: [{id: 'name', renderer: fplain, dataIndex: 'name'}],
|
||||||
|
sm: new Ext.grid.RowSelectionModel({
|
||||||
|
singleSelect: true,
|
||||||
|
listeners: {'rowselect': {fn: this.onPageSelect, scope: this}}
|
||||||
|
}),
|
||||||
|
hideHeaders: true,
|
||||||
|
autoExpandColumn: 'name',
|
||||||
|
deferredRender: false,
|
||||||
|
autoScroll: true,
|
||||||
|
margins: '5 0 5 5',
|
||||||
|
cmargins: '5 0 5 5',
|
||||||
|
width: 120,
|
||||||
|
collapsible: true
|
||||||
|
}, {
|
||||||
|
region: 'center',
|
||||||
|
title: 'Test',
|
||||||
|
margins: '5 5 5 5',
|
||||||
|
cmargins: '5 5 5 5'
|
||||||
|
}];
|
||||||
|
PreferencesWindow.superclass.constructor.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
Ext.extend(PreferencesWindow, Ext.Window, {
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
PreferencesWindow.superclass.initComponent.call(this);
|
PreferencesWindow.superclass.initComponent.call(this);
|
||||||
|
this.categoriesGrid = this.items.get(0);
|
||||||
this.categoriesGrid = this.add({
|
this.configPanel = this.items.get(1);
|
||||||
xtype: 'grid',
|
this.on('show', this.onShow.bindWithEvent(this));
|
||||||
region: 'west',
|
|
||||||
title: _('Categories'),
|
|
||||||
store: new Ext.data.SimpleStore({
|
|
||||||
fields: [{name: 'name', mapping: 0}]
|
|
||||||
}),
|
|
||||||
columns: [{id: 'name', renderer: fplain, dataIndex: 'name'}],
|
|
||||||
/*selModel: new Ext.grid.RowSelectionModel({
|
|
||||||
singleSelect: true,
|
|
||||||
listeners: {'rowselect': {fn: this.onPageSelect, scope: this}}
|
|
||||||
}),*/
|
|
||||||
hideHeaders: true,
|
|
||||||
autoExpandColumn: 'name',
|
|
||||||
margins: '5 0 5 5',
|
|
||||||
cmargins: '5 0 5 5',
|
|
||||||
width: 120,
|
|
||||||
collapsible: true
|
|
||||||
});
|
|
||||||
|
|
||||||
this.configPanel = this.add({
|
|
||||||
region: 'center',
|
|
||||||
title: 'Test',
|
|
||||||
margins: '5 5 5 5',
|
|
||||||
cmargins: '5 5 5 5'
|
|
||||||
});
|
|
||||||
|
|
||||||
this.currentPage = null;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
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', {});
|
||||||
|
|
Loading…
Reference in New Issue