Grid fixed width

Hi

I’m looking for a solution to limit the total width of columns to a particular value

Say I have a grid 800px width with 3 columns. 1st and 2nd cols are 200px, 3rd’s width is set to *, so it takes the rest, i.e. 400px.

When I start resizing the 2nd col it takes all possible width from the 3rd col and then a horizontal scroll bar appears and resizing continues to the right.

Is there any way to make that resizing stops when the 3rd column reaches its minimum width, so the total width of columns never exceeded the width of the grid (in my case 800px)?

Thank you

Victor

You may try to use the setColumnMinWidth() method:
docs.dhtmlx.com/doku.php?id=dhtm … mnminwidth

or enableAutoWidth() method:
docs.dhtmlx.com/doku.php?id=dhtm … eautowidth

Thank you

I tried both but this is not exactly what I need.

They do not limit the total column width and do not stop resizing

Victor

You may try to use the onResize event.
For example:

mygrid.attachEvent("onResize", function(cInd,cWidth,obj){ if (cInd==1&&cWidth>250) return false return true });

I played with onresize event, calculated the total width of columns and if it more than 800 returned false.

but this is not ideal, the event is not raised for every pixel, so even if I stop it the total width can be more than required.
there is also a hack required, if the width in your example goes more than 250, then you will not be able to resize the column back.

Ideally I’m looking for a native solution rather then a workaround

a good sample of what I need is here
demos.telerik.com/aspnet-ajax/gr … ultvb.aspx
make sure that “Resize grid on column resizing” is unchecked

Victor

The following solution works well for us.

mygrid.attachEvent("onResize", function(cInd,cWidth){ var wid=0; if (cInd==0){ wid=mygrid.getColWidth(1)+cWidth; } if (cInd==1){ wid=mygrid.getColWidth(0)+cWidth; } if (wid<650) return true; if (wid>=650) return false; });

Thank you, your solution works well, but not perfect, if I move mouse fast the grid can increase its size because the event is raised once for 5-10 pixels. My grid has 12 columns, I have a feeling that this delay depends on number of columns

My mistake was that I used getColWidth of the column beeing resized, rather than cWidth parameter

Anyway, thanks again, its much better than I had before