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)?
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
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
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan