andreiastra
1 Sep 2010, 3:18 AM
Hi,
I need to adjust the grid column widths that the grid data strings are shown completely. In other words, every time when the grid store is updated, I need to set each column width to the longest data string within the column.
I have a function that does it. It gets the text metrics from the first grid row:
void setColumnWidths(){
TextMetrics metrics = TextMetrics.get();
Element rowElement = grid.getView().getRow(0);
....
}
I call the function in
store.addListener(Store.DataChanged, handleWidths);
which works fine, except the very first time when the data gets loaded, but the grid is not displayed yet. In that case, I get rowElement=null.
I tried to call the setColumnWidths() function for different events with no success. I tried
Events.Show, Attach, ViewReady, Refresh, Render, RowUpdated on grid and grid view listeners, but I was getting rowElement=null.
Is my general approach to the problem correct? What event should I handle when the grid is displayed for the first time, but it's grid.getView().getRow(0) is not null?
I need to adjust the grid column widths that the grid data strings are shown completely. In other words, every time when the grid store is updated, I need to set each column width to the longest data string within the column.
I have a function that does it. It gets the text metrics from the first grid row:
void setColumnWidths(){
TextMetrics metrics = TextMetrics.get();
Element rowElement = grid.getView().getRow(0);
....
}
I call the function in
store.addListener(Store.DataChanged, handleWidths);
which works fine, except the very first time when the data gets loaded, but the grid is not displayed yet. In that case, I get rowElement=null.
I tried to call the setColumnWidths() function for different events with no success. I tried
Events.Show, Attach, ViewReady, Refresh, Render, RowUpdated on grid and grid view listeners, but I was getting rowElement=null.
Is my general approach to the problem correct? What event should I handle when the grid is displayed for the first time, but it's grid.getView().getRow(0) is not null?