cols[idx].setResizable( true );
cols[idx].setEditor( new GridEditor( new TextField() ) );
fds[idx] = new StringFieldDef( var );
idx++;
}
final RecordDef recordDef = new RecordDef( fds );
ArrayReader reader = new ArrayReader( recordDef );
MemoryProxy proxy = new MemoryProxy( model.getTableAsArray() );
ColumnModel cm = new ColumnModel( cols );
for ( int i = 0; i < cm.getColumnCount(); i++ ) {
cm.setEditable( i,
true );
}
store = new GroupingStore( proxy,
reader );
store.load();
grid = new EditorGridPanel( store,
cm );
grid.setStripeRows( true );
// GroupingView gv = new GroupingView();
GridView gv = new GridView();
// 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 );
grid.setAutoWidth( true );
grid.setAutoHeight( true );
Toolbar tb = new Toolbar();
Menu menu = new Menu();
menu.addItem( new Item( constants.AddRow(),
new BaseItemListenerAdapter() {
public void onClick(BaseItem item,
EventObject e) {
String[] rowData = new String[recordDef.getFields().length];
for ( int i = 0; i < rowData.length; i++ ) {
rowData[i] = "";
}
Record newRecord = recordDef.createRecord( rowData );
store.add( newRecord );
model.addRow( newRecord.getId(),
rowData );
}
} ) );