Monday, January 9, 2012

GWT CellTable getColumnWidth problem when inserting a Column object

Hello,

I am trying to implement dynamically resizable columns in GWT 2.4
CellTable. What I am trying to do here is that on the "mousedown"
event, I get the X,Y co-ordinates where the mousedown event occured
and also the Column in which it occured. Then I am trying to get the
Column object using getColumn(int columnIndex) method and it returns
me a Column object. The problem arises when I pass this Column object
to getColumnWidth() method because I want to calculate the original
width of the Column and then re-set it according to where the User-
clicks it (i.e. the X co-ordinate when the mouse down event occurs.)

Below is the code snippet :-

CellTable<String[]> cellTable = new CellTable<String[]>(10, tableRes);

// tableRes is a tableResources object to do custom styling on the
CellTable...

// I add some columns to the cellTable.... I have skipped that part of
code while posting here...The first column // added is a
CheckboxCell Column and rest are all TextCell columns.

cellTable.addCellPreviewHandler(new
CellPreviewEvent.Handler<String[]>() {
public void onCellPreview(CellPreviewEvent<String[]> event) {
String type = event.getNativeEvent().getType();
if (type.equals("mousedown")) {

int col = event.getColumn();
Column<String[], ?> column = (Column<String[], ?
> )cellTable.getColumn(col);

Window.alert("CLICKED" + col + "/" +
event.getNativeEvent().getClientX() + "/" +
event.getNativeEvent().getClientY());

int colOrigWidth =
Integer.parseInt(cellTable.getColumnWidth(column));
System.out.println("Column " + col + " Original Width : " +
colOrigWidth);
}
}
});


When I execute the code, I get an error in Development Mode window of
GWT, as stated below :-

00:01:30.782 [ERROR] Line 5257: The method
getColumnWidth(Column<String[],capture#3-of ?>) is undefined for the
type CellTable<String[]>

I guess the problem here is that the Column type arguments are either
Column<String[], Boolean> or Column<String[], String> and that is
causing the error ?

Any help would be appreciated as this issue that I am facing is
urgent. Thanks in advance.

P.S. :- The same error appears when I try to use setColumnWidth() as
well...

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment