Column width oddity, minimum width + hiding columns

Column width oddity, minimum width + hiding columns

kdorffkdorff Posts: 16Questions: 0Answers: 0
edited May 2012 in DataTables 1.9
Hi,

(I on May 25th revised this from my original post on May 24th as I determined why a fixed minimum width of about 175px was being used. This was my fault, I had a search input box in the footer that was about this width. The remaining two issues still exist.)

I am using DataTables 1.9.1. I am using jQueryUI:true. The table I am using uses sScrollX and sScrollY and I use Scroller so I can the data dynamically from the server. The table is physically wider (and obviously taller) than the screen, but the scrollbars works nicely, data is loading as expected, etc.

At initialization, I am setting all of my column widths using aoColumns and defining an sWidth (in pixels) for each column to a specific width. Such as [{sWidth:"50px"}, {sWidth:"250px"}, ...]. I am setting this width to accommodate the width of the title, so the title it doesn't wrap.

First, It appears that when bAutoWidth : false, DataTables completely ignores my aoColumns sWidth specifications. If I leave out bAutoWidth or set bAutoWidth : true, it respects the column widths I specify in aoColumns. Is this expected behavior?

Secondly and more importantly, I am using a column chooser (my own) to show/hide column (any column with a visibility change, I call fnSetColumnVis (colNo, true/false, false) then after all the changes, I call fnDraw (true) (I've also tried fnDraw (false)). What appears to be happening is that if I eliminate some columns, the (virtual) width that the table consumed before (given that the width of my table started much larger than the width of the screen using the X scrollbar to view the whole table) isn't reduced to account for the new, reduced number of columns. The result is that the remaining columns are all much wider than before, even though I've pre-specified the desired column size using aoColumns. I've testing removing columns with both bAutoWidth set to both true and false and there was no difference with this behavior.

Any input or insight would be greatly helpful.

Thanks,
Kevin

Replies

  • kdorffkdorff Posts: 16Questions: 0Answers: 0
    I did a bit more searching and solved the second question on my own. I was doing some number of fnSetColumnVis (colNo, true/false, false) followed later by a call to fnDraw. I replaced the call to fnDraw with a call to fnAdjustColumnSizing (true) and now the column widths are correct after removing columsn. Yay!

    That just leaves the first question. If I set bAutoWidth to false, DataTables ignores my predefined column width. As it my table is working I am not complaining, but is this expected behavior?
This discussion has been closed.