Friday, November 9, 2007

Smart column width based on data displayed (Part One: No code yet)

From the poll conducted I find that many users want Smart column width based on data displayed in DG/ADG.

I hope people requesting this feature know that it is a CPU intensive process to go over all the items in the dataProvider to find out maximum width required for all the columns. If the number of visible columns is more it would take even more time to compute the values and layout the columns.

If a labelFunction is being used at DG or DGColumn level and custom styles have been used on a column for fontSize for example, it complicates the computation even more.

When the data is being paged from a server it is not possible to compute the smart width at all without requesting all the data from the server, which is never desirable.

Keeping these things in mind I feel it makes sense to have a flag on individaul DGcolumn (apart from one on the DG itself) to control the computation of smart width. If the flag is true width is computed and false would use the normal way of determining the column width.

Thoughts?

3 comments:

Unknown said...

Hi, I think this is exactly what I need to do. I want the columns to be as wide as they need t be to display all of the data, even if this means that the AdvancedDataGrid ends up wider than the browser. You say 'no code yet'... does this mean that you are planning to put some code up to do this? I'm really struggling to find a way to do this. Any pointers would be much appreciated. Thanks. Angie

Sreenivas said...

I am yet to write the code. Here are some thoughts.
There are two approaches possible.

1. Iterate over all items in the collection, iterate over each column and find the maximum width required for each column. Update the column widths based on this computation.

Advantages of this approach:

a. DG/ADG can return the exact width required to display data without truncation/wrapping.

b. Very good user experience/navigation.

Disadvantages of this approach are
(in no particular order)

a. It might take long time to load the DG/ADG because of computation.

b. If data is getting lazily loaded the computation cannot be completed. It might be hit with ItemPendingErrors.

2. Modify column widths as and when data becomes visible due to scrolling.

Disadvantages of this approach are
(in no particular order)

a.It might annony users that column widths are changing when they scroll.

b.DG/ADG would not be able to return the exact width required in the measure function because it has not computed the max width requried for each column for all data by then.

These are my initial thoughts. I have tried to implement both approaches but never got to complete it.

Sriku said...

Hi, Can u provide a code snippet of using custom header renderer for Olap datagrid