I’m trying to create grid extension to recalculate column width when the grid scroll as suggested at this ticket: https://dev.vaadin.com/ticket/17438.
So, I’m following UI extension tutorial on Book of Vaadin chapter 16.7. I’ve create server side extension and the connector. See my code below
The extension
import com.vaadin.server.*;
import com.vaadin.ui.*;
public class gridAutoResize extends AbstractExtension {
public gridAutoResize(Grid grid) {
extend(grid);
}
public void extend(Grid grid) {
super.extend(grid);
}
public static void addTo(Grid grid) {
new gridAutoResize(grid);
}
}
The connector
import com.vaadin.client.widget.escalator.*;
import com.vaadin.client.widgets.*;
import com.vaadin.client.*;
import com.vaadin.client.extensions.*;
import com.vaadin.shared.ui.*;
@Connect(gridAutoResize.class)
public class gridAutoResizeConnector extends AbstractExtensionConnector {
@Override
protected void extend(ServerConnector target) {
// Get the extended widget
Grid<?> pw = (Grid<?>) ((ComponentConnector) target).getWidget();
pw.addRowVisibilityChangeHandler(new RowVisibilityChangeHandler() {
@Override
public void onRowVisibilityChange(RowVisibilityChangeEvent event) {
if ((event.getFirstVisibleRow() % event.getVisibleRowCount()) == 0) {
pw.recalculateColumnWidths();
}
}
});
}
}
And then I simply attach the extension to my grid
gridAutoResize.addTo(grid);
After I ran the code, the grid didn’t resize automatically when I scrolling.
I know I’ve missed something, but I don’t know what it is. I’m still confuse about server/client side thing. I need any assistance, please.
@SuppressWarnings(“serial”) @Connect(com.mylib.extension.gridautoresize.gridAutoResize.class)
public class gridAutoResizeConnector extends AbstractExtensionConnector {
}
[/code]The first dialog box is successfully showing “connector enabled = true”, so I think the connector is already worked.
The problem is the handler I added to the widget, when I scroll the table, it should showing the dialog box saying “enter scroll”, but it didn’t.
I already tried with addDomHandler, addBitlessDomHandler, addHandler, combine with ScrollHandler and RowVisibilityChangeHandler, but no luck here.