Jump to content

UniDBGrid Column autofit


okkoos

Recommended Posts

Hi

how can I set Ext.grid.Panel.forcefit property to true for autofit of UniDBGrid columns.

 

 

quotation from http://docs.sencha.com/ext-js/3-4/#!/api/Ext.grid.GridPanel  below;

 

" forceFit : Boolean2

Ttrue to force the columns to fit into the available width. Headers are first sized according to configuration, whether that be a specific width, or flex. Then they are all proportionally changed in width so that the entire content width is used.

Available since: Ext 4 "

regards.

 

Link to comment
Share on other sites

Hi,

 

UniGui using Extjs 4.1.1 and this method has been changed, so I use this to auto resize columns at Client Side:

 

 



 function OnResize(sender, adjWidth, adjHeight, rawWidth, rawHeight)
{
  //get grid new width
  var grd_w=sender.getWidth();
  //validate
  if(sender.columns.length==0) return;
  //auto resize columns
  crnt_w=0.073*grd_w; //Calc width in 7.3%
  crnt_w=Math.floor(crnt_w);
 //change column width: strat from 1 for first column (when indecator is true) otherwize start from 0
 sender.columns[1].setWidth(crnt_w);//first column (0: is the indecator)
}







Link to comment
Share on other sites

Hi,

 

It's working greate !

 

1. the 'OnResize' is an event for the DBGRID in Client Side Events, please follow me:

 

grd1.jpg

 

 

 

 

 

 

grd2.jpg

 

 

Don't forget this line (it's very important):

 

  //validate
  if(sender.columns.length==0) return;
 

Link to comment
Share on other sites

  • 4 months later...

Hi. 

You can make so:
 

function OnReconfigure(sender, store, colModel)
{
sender.headerCt.forceFit=true;
}

 

or, for specified columns:

 

 

function OnReconfigure(sender, store, colModel)
{
if (!sender.columnManager) {
sender.columns[0].flex=1;
} else {
sender.columnManager.columns[0].flex=1;
}

}

 

in unidbgrid.ClientEvents.ExtEvents

Link to comment
Share on other sites

  • 1 year later...

Hi. 

You can make so:

 

function OnReconfigure(sender, store, colModel)

{

sender.headerCt.forceFit=true;

}

 

or, for specified columns:

 

 

function OnReconfigure(sender, store, colModel)

{

if (!sender.columnManager) {

sender.columns[0].flex=1;

} else {

sender.columnManager.columns[0].flex=1;

}

 

}

 

in unidbgrid.ClientEvents.ExtEvents

hi

this solution not work in Grouped UniDBGrid.

tnx.

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...

Hi. 

You can make so:

 

function OnReconfigure(sender, store, colModel)

{

sender.headerCt.forceFit=true;

}

 

in unidbgrid.ClientEvents.ExtEvents

 

Hi,

When I use:

sender.headerCt.forceFit=true;

 the result is this:

https://www.dropbox.com/s/sxwmwsmvscar3uw/UniGui_Grid.png?dl=0

 

 

Does anyone know how to solve it? The scroll disappears and it tries to fit into a single page.

What the property tries to do is to divide the size of the Grid by the existing columns. Right?

What I want is that the width of the column is the size of the largest text inserted in it.

Link to comment
Share on other sites

  • 2 weeks later...
 
First of all, thank you very much for your response.
This works, but it's slow for me to load 25 records with 60 columns, or maybe I'm doing something wrong.
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...