Friday, January 13, 2012

AdvancedDataGrid scroll

So, I was working on spitting the AdvancedDataGrid into PDF Files. I needed to programatically get the number of pages in the AdvancedDataGrid based on the scrollbar and then create the pages in PDF when I noticed this behaviour.
What happened was that initially I got the number of pages as say 3, based on the maxScrollPosition and pageSize. But when I exported it into PDF I got just 2 pages. Curiously enough I dug to find in the issue.

Turns out that the AdvancedDataGrid's horizontal scrolling is a bit peculiar, in that it sizes the horizontal scroll thumb based on the width of the visible columns

So, what was happening was that the datagrid in question was dynamically adding the columns. So initially it calculated the maxScrollPosition and pageSize based on the original page size and sroll in the grid. When the scroll was done the scrollbar is resized and all calculations go haywire.

I guess this is probably good for the performance, since the grid does not need to add the columns in the start, but it sure is causing me a nightmare... Hope to get some workaround for this. Fingers crossed.

No comments :