PDA

View Full Version : Window Scroll Bar Jumping



swaitch
10 Sep 2010, 3:57 PM
I have a window that contains a grid. I want it to scroll to show items beyond the set height of the window. This is working, however when I click on an item that is below the set height the scrollbar jumps back to the top and I have to scroll back down to see my selected item. Annoying!

Grid and panel:


var inventoryGrid = new Ext.grid.EditorGridPanel({
id: 'inventoryGrid',
autoHeight:true,
store: inventoryStore,
columLines: true,
cm: inventoryCM,
sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
gridContextMenu: true,
loadMask: true,
viewConfig: {
forceFit: true,
enableRowBody: true
},
listeners: {
'afteredit': function(e){
var conn = new Ext.data.Connection();
conn.request({
url: 'action/queries.php',
params: {
task: 'updateInventory',
printerid: e.record.id,
field: e.field,
value: e.value
},
success: function(f,a) {
inventoryStore.load({params: {task:"getInventory"}});
},
failure: function(f,a) {
Ext.Msg.alert('Failure', Ext.decode(f.responseText).errormsg);
}
});
}
}/*,
bbar: new Ext.PagingToolbar({
pageSize: 50,
store: inventoryStore,
displayInfo: true,
displayMsg: 'Displaying {0} - {1} of {2}'
})
*/
});

inventoryGrid.show();
inventoryStore.load({params:{start:0,limit:50}});

Ext.override(Ext.grid.GridView, {
syncFocusEl : Ext.emptyFn
});

var inventoryWindow = new Ext.Window({
closable: true,
width: 550,
height: 500,
autoScroll: true,
modal: false,
x: 350,
y: 200,
title: 'Cartridge Inventory',
items: [inventoryGrid]
});
inventoryWindow.show();
Click here to view a jing video of the problem: http://screencast.com/t/ZWIxZjE4Y

Thanks for any help in advance,

Swaitch

Condor
10 Sep 2010, 11:23 PM
1. Your window should be configured with autoScroll:false and layout:'fit' and your grid with autoHeight:false.
2. Don't call inventoryGrid.show() (it is contained in a window - why would you want to show it separately?).
3. Why did you override syncFocusEl? That is probably the cause of your problem!

swaitch
13 Sep 2010, 6:31 AM
Thanks, Condor! Those changes worked perfectly.

Obviously I have some bad coding habits from the beginning, thanks for the tips.