Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem getting a GridPanel to show data from a String[][]

843806Jun 28 2008 — edited Jun 28 2008
I hope this is the right forum, i have a problem with GWT...

I have a GridPanel and want to submit a String[][] to it. I also have 2 comboboxes (named cbA and cbB) where i should be able to pick among the different columns in the GridPanel after the String[][] is submitted (but thats another problem i will come to later). The grid is added to RootPanel.get() in the onModuleLoad() method, i know that is working as it should. The problem is in the updateGrid() method below, that is supposed to make the GridPanel show the data in String[][]. Note that the method should be able to work for a String[][] of any size, thats the reason i use the for-loop you can see. The problem is, of course, that the data wont show in the grid, and running in hosted mode i get a popup error saying "Cannot change configuration property 'cm' after the component has been rendered." I dont fully understand the use of Store, ColumnConfig, RecordDef, MemoryProxy, ArrayReader, so i didnt expect it to work at first try, but it also makes it hard for me to get rid of errors. Can you guys help me out? :)
private ComboBox cbA;
private ComboBox cbB;
private String[][] data = new String[rows][columns]; //This two-dimensional array has a lot of data
private RecordDef recordDef;
private MemoryProxy proxy;
private ArrayReader reader;
private Store gridStore;
private ColumnConfig[] columnConfig;
private ColumnModel columnModel;
public void updateGrid() {
		cbA.clearValue();
		cbB.clearValue();
		gridStore.removeAll();
		//geneStore.removeAll();
		//dataStore.removeAll();
		columnConfig = new ColumnConfig[columns];
		
		FieldDef[] fields = new FieldDef[columns];  
		for (int i=0; i<columns; i++){
        	fields[i] = new StringFieldDef("sfd");
        	columnConfig[i] = new ColumnConfig("column"+i,"column"+i,90); 
		}
		
		columnModel = new ColumnModel(columnConfig);
		gridPanel.setColumnModel(columnModel); //---AT THIS LINE I GET THE ERROR---
		recordDef = new RecordDef(fields);
		proxy = new MemoryProxy(data);  
        reader = new ArrayReader(recordDef); 
        gridStore = new Store(proxy, reader);  
        gridStore.load();
        //gridStore.reload();
	}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 26 2008
Added on Jun 28 2008
3 comments
135 views