final RecordDef recordDef = new RecordDef( fds );
ArrayReader reader = new ArrayReader( recordDef );
MemoryProxy proxy = new MemoryProxy( dt.data );
ColumnModel cm = new ColumnModel( cols );
store = new GroupingStore();
store.setReader( reader );
store.setDataProxy( proxy );
store.setSortInfo( new SortState( "num",
SortDir.ASC ) ); //NON-NLS
if ( this.dt.groupField != null ) {
store.setGroupField( dt.groupField );
}
cm.addListener(new ColumnModelListenerAdapter(){
public void onHiddenChange(ColumnModel cm, int colIndex,
boolean hidden) {
final String dta = cm.getDataIndex(colIndex);
if (colMap.containsKey(dta)) {
DTColumnConfig col = colMap.get(dta);
col.hideColumn = hidden;
}
}
});
store.load();
final GridPanel grid = new GridPanel( store,
cm );
grid.setStripeRows( true );
grid.addGridColumnListener( new GridColumnListener() {
public void onColumnMove(GridPanel grid,
int oldIndex,
int newIndex) {
if ( DecisionTableHandler.validateMove( dt,
oldIndex,
newIndex ) ) {
// Save any changes to the dt.data.
scrapeData( -1 );
DecisionTableHandler.moveColumn( dt,
oldIndex,
newIndex );
grid = doGrid();
} else {
// Refresh undoes the move.
refreshGrid();
ErrorPopup.showMessage( constants.CanNotMoveColumnsFromOneTypeGroupToAnother() );
}
}
public void onColumnResize(GridPanel grid,
int colIndex,
int newSize) {
// Nothing
}
} );
GroupingView gv = new GroupingView();
//to stretch it out
gv.setForceFit( true );
gv.setGroupTextTpl( "{text} ({[values.rs.length]} {[values.rs.length > 1 ? \"" //NON-NLS
+ constants.Items() + "\" : \"" + constants.Item() + "\"]})" );
grid.setView( gv );
grid.setStore( store );
int width = 900;
if ( cm.getColumnCount() > 10 ) {
width = 900 + (90 * (cm.getColumnCount() - 10));
}
grid.setWidth( width );
grid.setHeight( 500 );
//Add the cell listener for when the user wants to edit.