browse by category or date

After upgrading to Ext.NET 1.4, I found out a weird bug with GridPanel. I have a GridPanel which is inside a Container. I set the Container’s layout to FitLayout because I want the GridPanel to occupy all the available space. To ensure that the width is fully used, I set the GridPanel’s AutoExpandColumn property to one of the column.

With that in mind, the GridPanel is expected not to have a horizontal bar. But somehow the horizontal scrollbar appears.

It gets worse when I scrolled it right until the end, the GridPanel’s content is now misaligned to its header.

This problem will not happen if I am not using the AutoExpandColumn property and set the columns width within the available space. I also found out that the horizontal scrollbar will disappear if I manually reduce the size of any column.

With that, I can positively identify that the bug lies in the way AutoExpandColumn works. To solve this, I could either dig deep to Ext.NET internals, or I just use a “duct tape solution”.

Due to time constraint, I’ll just use the “duct tape” solution for now. What we’re going to do is to reduce the column’s width after the data is loaded. I recommend to choose the column that is used as AutoExpandColumn as the target.

Assume that you already have the GridPanel, we will handle the Store’s Load event with fnResizeColumn function.

<ext:GridPanel ButtonAlign="Center"  
	ID="gv" runat="server" Header="false" 
	Border="false" AutoExpandColumn="Title">
		<ext:Store ID="ds" runat="server" RemoteSort="true" 
		UseIdConfirmation="true" AutoLoad="true">
					..... SNIP .... 
					..... SNIP .... 
					..... SNIP .... 
				<Load Fn="fnResizeColumn" />
		..... SNIP .... 

The fnResizeColumn method is quite simple.

var fnResizeColumn= function(obj) {
	var colModel = gv.getColumnModel();	
	//reduce the Column width by 50 pixels
	colModel.setColumnWidth(1, //zero-based column index
		colModel.getColumnWidth(1) - 50);            

There you go, fast and easy!

I hope it helps. Cheers!

GD Star Rating
Solving Ext.NET GridPanel AutoExpandColumn Horizontal Scrollbar Bug, 5.0 out of 5 based on 1 rating

About Hardono

Hi, I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

No Comment

Add Your Comment