Jump to content

dbGrid forceFit


soledue

Recommended Posts

Add on MainForm.Script

 

function OnGridResize(sender, adjWidth, lastColNotResize)

{

var TotWidth=0, VarWidth=0, ResizableColumnCount=0, i1=0, i2=0,

colModel=sender.getColumnModel();

lastColNotResize=lastColNotResize||0;

if (lastColNotResize>0) {i2=lastColNotResize}

else {i1=-lastColNotResize};

for(i=1;i<colModel.columns.length;i++)

{TotWidth+=colModel.columns.width;

ResizableColumnCount++;}

TotWidth+=colModel.columns.length;

VarWidth=adjWidth-TotWidth;

if ((ResizableColumnCount-i1-i2)>0){VarWidth=VarWidth/(ResizableColumnCount-i1-i2)}

for(i=1+i1;i<colModel.columns.length-i2;i++)

{colModel.setColumnWidth(i, colModel.columns.width+VarWidth)}

}

 

and

 

Add on unidbgrid.ClientEvents

 

function OnReconfigure(sender, store, colModel)

{

OnGridResize(sender, sender.width, 3);

}

and

 

function OnResize(sender, adjWidth, adjHeight, rawWidth, rawHeight)

{

OnGridResize(sender, adjWidth, 3);

}

Link to comment
Share on other sites

Great! but if "forceFit" there why not use it?

 

 

 

Add on MainForm.Script

 

function OnGridResize(sender, adjWidth, lastColNotResize)

{

var TotWidth=0, VarWidth=0, ResizableColumnCount=0, i1=0, i2=0,

colModel=sender.getColumnModel();

lastColNotResize=lastColNotResize||0;

if (lastColNotResize>0) {i2=lastColNotResize}

else {i1=-lastColNotResize};

for(i=1;i<colModel.columns.length;i++)

{TotWidth+=colModel.columns.width;

ResizableColumnCount++;}

TotWidth+=colModel.columns.length;

VarWidth=adjWidth-TotWidth;

if ((ResizableColumnCount-i1-i2)>0){VarWidth=VarWidth/(ResizableColumnCount-i1-i2)}

for(i=1+i1;i<colModel.columns.length-i2;i++)

{colModel.setColumnWidth(i, colModel.columns.width+VarWidth)}

}

 

and

 

Add on unidbgrid.ClientEvents

 

function OnReconfigure(sender, store, colModel)

{

OnGridResize(sender, sender.width, 3);

}

and

 

function OnResize(sender, adjWidth, adjHeight, rawWidth, rawHeight)

{

OnGridResize(sender, adjWidth, 3);

}

Link to comment
Share on other sites

  • 7 months later...
  • 3 weeks later...

also

for certain columns you can make, for example:

 

function OnReconfigure(sender, store, colModel)
{var col;

if (!sender.columnManager) {
col=sender.columns;
} else {
col=sender.columnManager.columns;
}
col[0].flex=1;
col[2].flex=1;
col[5].flex=1;

}

Link to comment
Share on other sites

  • 2 years later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...