PDA

View Full Version : Grid Usage Advice Please!!!



Shawn.in.Tokyo
26 Jun 2009, 5:03 PM
How can I use a grid to display and edit data that may be different for each row.

Example.

class Country
String name
int government_type

Depending on government_type I want to show and edit a subclass of Country which have different fields as suitable for the government_type

Idea:

A] Can I do this with a straight editable grid? http://extjs.com/examples-dev/explorer.html#editablegrid

B] Could I use grid/roweditor.html and have the roweditor display different editable fields depending on government_type http://extjs.com/examples-dev/explorer.html#roweditorgrid

C] Should I use a GridStoreBinding -- displaying the country in the Grid and on selection display the Country and subclass a seperate editable form. http://extjs.com/examples-dev/explorer.html#gridstorebinding

D] Could I display the information using an expander row? If so, how do I get GXT to display based on government_type ex. http://extjs.com/examples-dev/explorer.html#gridstorebinding and perhaps combine this with C] so the the country info will display, the gov_type subclass info will display if expand is selected and the the country and gov_info will be editable in a seperate form if the row is selected.

All the Best,

Shawn

jamelboubaker
29 Jun 2009, 6:01 AM
Can you help me, i dont inderstand the principe of store :

Grid grid = new Grid(store, cm);

cm -> is the column model, i indertand it.

but : ListStore store = new ListStore(); is not easy for yungs developpers I-|

we supose that i'd like to show informations about this JavaBean in myGrid :

class Person{
String firstName,lastName,country;
//getters and setters....
//....
//....

}

can you give me the true construction of store and colulnModel?

THANKS!

sven
29 Jun 2009, 7:07 AM
The Store is holding all the models that you want to display in your grid. You have to add each model to the store and it gets automatically displayed in the grid.

I suggest to look at the examples in the explorer. They show exactly how to do this.

jamelboubaker
29 Jun 2009, 11:50 PM
Thanks for your answer!

I saw the example in Explorer, i'm near to the solution! but i would like to inderstand more the principe of store!

this question show what i want to know !

----> i have one Java bean which has 5 attributs :
1- id
2-firstName
3-lastName
4-age
5-job

------> in the grid i like to show only 3 attributs

1-lastName
2-age
3-job


============================
i try to construct the column model like that
============================


List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

ColumnConfig column = new ColumnConfig();
column.setId("lastName"); /// it is thee link between store and column model??
column.setHeader("Last Name");
column.setWidth(100);
configs.add(column);

ColumnConfig column = new ColumnConfig();
column.setId("age"); /// it is thee link between store and column model??
column.setHeader("Age");
column.setWidth(100);
configs.add(column);


ColumnConfig column = new ColumnConfig();
column.setId("job"); /// it is thee link between store and column model??
column.setHeader("Job");
column.setWidth(100);
configs.add(column);

ColumnModel cm = new ColumnModel(configs);


==========
my question is :
==========
:-/
i would like to construct a store which show only 3 attributs:

lastName | age | job

not 5 ttributs :((:

id | firstName | lastName | age | job


Thanks !!!!