View Full Version : Populate Grid with Data from XML

7 Mar 2011, 2:07 AM
I read the example from http://www.sencha.com/examples/explorer.html#xmlgrid, but i would like
not to use the loader and the reader since my data are retrieved in a different way.

I have a dataset object which contains an ArrayList<String> of columnNames, and a List<Rows> which contains the data from the XML parsed as a List of Rows, where each Rows extends ModelData.

// building grid store
ListStore<ModelData> store = new ListStore<ModelData>();
store.add((List<? extends ModelData>) dataset.getRows()); // each Row extends ModelData

ArrayList<String> nameList = dataset.getColumnNames();

// Building column model
ColumnConfig column;
ArrayList<ColumnConfig> configs = new ArrayList<ColumnConfig>();
for(String columnName : nameList) {

column = new ColumnConfig();
ColumnModel cm = new ColumnModel(configs);

Grid grid = new Grid(store, cm );

The rendered Grid is empty, while the column names are not. So i believe i am making a mistakes in building the Grid Store and/or the single Rows objects.
Is it because i have to use a specific property name into the ModelData object in order to be visualized into the Grid?

Thanks for the help

31 Mar 2011, 4:58 AM
Yes, property name that corresponds to the column id, e.g.
row.set("name", name);
row.set("surname", surname);