PDA

View Full Version : [CLOSED] 2.0M3 Grid Header Bug



yafmbl
16 Jun 2009, 2:38 AM
Hi,

Platform Info:
GXT Version: Latest from SVN (as of 2009-06-16) (PS: Tested with 2.0M3 release as well, same issue there)
Hosted mode & Web Mode (IE/FireFox/Chrome/Safari)
Windows XP sp3

Problem:

We have an issue with the grids. Seemingly, grids are aligning the column headers in a weird way. (see the screenshot for a better understanding)

14316

The distrubtion gets one pixel more with each additional column. The first grid has 4 columns, and the 2nd one has 144 columns. (it gets weirder if you keep increasing the column count)

Also, when you move mouse over the header, it changes the alignment of the titles. (i marked those columns in the attachment)

here is the sample code which produces the effect.




public void onModuleLoad( )
{
try
{
Viewport viewPort = new Viewport( ) ;
viewPort.setLayout( new FitLayout( ) ) ;
viewPort.add( getTestWidget( ) ) ;
RootPanel.get( ).add( viewPort ) ;
}
catch( Throwable t )
{
t.printStackTrace( ) ;
}
}

public LayoutContainer getTestWidget( )
{
LayoutContainer container = new LayoutContainer( ) ;
Grid<ModelData> grid ;
container.setLayout( new FlowLayout( ) ) ;

List<ColumnConfig> configs = new ArrayList<ColumnConfig>( ) ;

for( int i = 0; i < 4; i++ )
{
ColumnConfig fx = new ColumnConfig( "f" + i, "f" + i, 100 ) ;
configs.add( fx ) ;
}

ColumnModel cm = new ColumnModel( configs ) ;

ListStore<ModelData> store = new ListStore<ModelData>( ) ;

grid = new Grid<ModelData>( store, cm ) ;
grid.setStyleAttribute( "borderTop", "none" ) ;
grid.setAutoExpandColumn( "f1" ) ;
grid.setBorders( true ) ;
grid.setStripeRows( true ) ;

container.add( grid ) ;

//Add second one

configs = new ArrayList<ColumnConfig>( ) ;

for( int i = 0; i < 144; i++ )
{
ColumnConfig fx = new ColumnConfig( "f" + i, "f" + i, 30 ) ;
configs.add( fx ) ;
}

cm = new ColumnModel( configs ) ;

store = new ListStore<ModelData>( ) ;

grid = new Grid<ModelData>( store, cm ) ;
grid.setStyleAttribute( "borderTop", "none" ) ;
grid.setAutoExpandColumn( "f1" ) ;
grid.setBorders( true ) ;
grid.setStripeRows( true ) ;

container.add( grid ) ;

return container ;
}



During debug, we also found some clues about source of the problem. The below method in ColumnHeader.java calculates height 1 more at each iteration:




// line 546 as of SVN version 2009-06-16

protected void adjustHeights() {
for (Head head : heads) {
if (head.isRendered()) {
// THIS ONE CALCULATES HEIGHT 1 MORE AT EACH ITERATION
int h = head.el().getParent().getHeight();
head.el().setHeight(h, true);
}
}
}



Thanks for the help.

dron
17 Jun 2009, 11:30 PM
did you upgrade .jar file and resources files too? Because I had similar problem when I upgraded .jar file and forgot resources(*.css etc.)

yafmbl
17 Jun 2009, 11:54 PM
Thank you dron, upgrading the resources did the trick.

sven
17 Jun 2009, 11:57 PM
I am closing the issue than.

tslusser
17 Jul 2009, 1:56 PM
Hi. I am experiencing this problem still in 2.0 final. I believe the problem is in the adjust heights method as pointed out by a previous post. I don't believe this is related to CSS as I can step through the Java code in a debugger and see the height value incrementing by 1 per each iteration of


for (Head head : heads) {
if (head.isRendered()) {

int h = head.el().getParent().getHeight();
/* which ultimately calls a gwt native method Element.getOffsetHeight */


head.el().setHeight(h, true);
}
}


so it's not clear to me whether this is a bug in gxt or in gwt?

I see this issue in both gwt 1.6.4 and 1.7.0

Thanks,
Ted

sven
17 Jul 2009, 2:08 PM
Are you sure you are using the latest CSS resources?

tslusser
17 Jul 2009, 2:14 PM
I am pretty sure. I have copied over all the CSS, images, themes, etc from the gxt-2.0 download. Is there a particular file timestamp or checksum I can verify?

tslusser
17 Jul 2009, 5:45 PM
Interesting.... I looked at the header of the gxt-all.css and it states 2.0-M1 as the version. I re-downloaded the gxt-2.0.zip just now and it says 2.0

I don't know if this was something I did wrong in unpacking the zip file or in the packaging but anyway, my problem is resolved now.

Thanks,
Ted