PDA

View Full Version : [Grid] autoSizeColumns doesn't consider the vertical scroll



Skeleton
1 Mar 2007, 1:46 AM
Whenever I set autoSizeColumns property to true while constructing a grid, it doesn't consider the vertical scrollbar width (which is shown when there are rows that doesn't fit in viewport of grid). So this results an ugly horizontal scrollbar. I know the scrollbar widths are slightly differnt on different platforms (even on the same platform using different OS level skins/themes) but it would be good to consider that width approximately 20-30px and calculate the column widths accordingly.

jack.slocum
1 Mar 2007, 10:44 AM
Is you data inline or loaded async?

JeffHowden
1 Mar 2007, 12:04 PM
Mine is loaded asynch and it does what the OP describes both with autoWidth set to true or autoSizeColumns set to true.

jack.slocum
1 Mar 2007, 12:10 PM
As in .33, autoSizeColumns config option will only work with inline data. The problem is it doesn't know if your store is loading async, if it's already been loaded, etc. However, you can do:


ds.on('load', function(){
grid.getView().autoSizeColumns();
}, false, {single:true});

The single:true option is so it only does it on the first load, in case they have resized columns.

JeffHowden
1 Mar 2007, 12:27 PM
Thanks Jack, that worked a treat. I found something interesting though. I happened to have another ds.on('load', ...) applied. I couldn't mix them because the other one I want/need to have run everytime the datastore loads. I discovered that the order is crucial. If I specify the one in your response first, then it throws a JS error:


l has no properties
http://ondemand.aicproperties.com/scripts/ext-all-debug.js
Line 1320

However, if I place it after my original one, it executes without any troubles.

Throws the error:


ds.on('load', function() {
grid.getView().autoSizeColumns();
}, false, { single: true });

ds.on('load', function() {
var count = ds.getCount();
var msg = count == 0 ?
'Data not available for this view.' :
String.format(
'Displaying {0} - {1} of {2}',
paging.cursor + 1, paging.cursor + count, ds.getTotalCount()
);
displayInfo.update(msg);
fewer.setDisabled(paging.pageSize <= 20);
more.setDisabled(paging.pageSize + 20 >= ds.getTotalCount());
});

Does not throw the error


ds.on('load', function() {
var count = ds.getCount();
var msg = count == 0 ?
'Data not available for this view.' :
String.format(
'Displaying {0} - {1} of {2}',
paging.cursor + 1, paging.cursor + count, ds.getTotalCount()
);
displayInfo.update(msg);
fewer.setDisabled(paging.pageSize <= 20);
more.setDisabled(paging.pageSize + 20 >= ds.getTotalCount());
});

ds.on('load', function() {
grid.getView().autoSizeColumns();
}, false, { single: true });

jack.slocum
1 Mar 2007, 2:52 PM
This is fixed Jeff. Sorry about that.