Question: Resizing dynamic columns to fix content width - Pa

Hello,

According to your reply (dhtmlx.com/docs/products/kb/inde … 566&a=4958)
it is only possible to define fixed width for all the columns except one in case I’d like to be able to resize
these columns later. This is not an option in my case, so I ready to omit the resizing feature. But it is a
must to have columns that adjust their width according to the content (both ways - shrink and grow),
and fill all the available table width. It would be desirable to respond to the change of the table
container div width (as a result of window resize, for example) and fill again the new table width.
Is this possible? Right now I am running the following configuration XML, but the columns
not adjusted to fit content width, and after table container div resize I have to resize any column to make
the last one fill the available space.

<?xml version="1.0" encoding="UTF-8"?>

   
       
       
       
       
       
   
   
        px
   
   
       
            true
            true
            true
            true
            true
       
   
   
       
            0
       
       
            1
       
       
            2
       
       
            3
       
       
            4
       
   
   
       
       
       
       
       
   


Regards,
Yuri

>> it is only possible to define fixed width for all the columns except one in case I’d like to be able to resize these columns later.
This is correct, the column must have fixed width if you plan to resize it.

>>But it is a must to have columns that adjust their width according to the content (both ways - shrink and grow), and fill all the available table width
The provided  requirements are mutual exclusive - the column can’t adjust its size to the inner content , and adjust its size to fill all available space in grid.
The existing design allows two solution
    a) define single flexible column ( width="*" ) and use adjustColumnSize against other columns - in such case all columns will be autosized to data, and column marked as flexible - take all available space
    b) use enableAutoWidth and adjustColumnSize  against all columns - in such case all columns will be adjusted by data size, and grid itself will change size to prevent empty space or scroll.
    c) you can define initial width in percents -  in such case columns will correctly increase width on window resizing, but they will ignore size of data in them.
   
>>and after table container div resize I have to resize any column to make the last one fill the available space.
The grid is not able to detect the resize of parent container, if you resizing parent container by some custom code just add
    grid.setSizes()
after it, this command will force grid sizes update.

>> I am running the following configuration XML, but the columns not adjusted to fit content width
The situation is next - the command from afterInit section called when configuration already loaded, but data part of grid not filled yet, so on moment of call - there is no data, which can be used for column adjusting. Basically the command need to be called from after-loading handler in js code, while call from XML can be done technically - it can’t be done with correct timing.