@SuppressWarnings("unchecked")
public void bindGrid(Grid grid) {
if (this.grid != null) {
this.grid.removeListener(Events.RowMouseDown, this);
this.grid.removeListener(Events.RowClick, this);
this.grid.removeListener(Events.ContextMenu, this);
this.grid.removeListener(Events.ViewReady, this);
this.grid.getView().removeListener(Events.RowUpdated, this);
this.grid.getView().removeListener(Events.Refresh, this);
this.grid.getColumnModel().removeListener(Events.HiddenChange, this);
keyNav.bind(null);
bind(null);
}
this.grid = grid;
if (grid != null) {
grid.addListener(Events.RowMouseDown, this);
grid.addListener(Events.RowClick, this);
grid.addListener(Events.ContextMenu, this);
grid.addListener(Events.ViewReady, this);
grid.getView().addListener(Events.RowUpdated, this);
grid.getView().addListener(Events.Refresh, this);
grid.getColumnModel().addListener(Events.HiddenChange, this);
keyNav.bind(grid);
bind(grid.getStore());
grouped = grid.getView() instanceof GroupingView;
if (grouped) groupingView = (GroupingView) grid.getView();
}
}