PDA

View Full Version : Convert Grid into TreeGrid (ListStore to TreeStore)



schube
7 Jan 2010, 4:40 PM
Hi!

I have organised my data in a grid (no paging, to make things simpler).

The data looks like that:



ID| Category| Status| FieldA| FieldB| FieldC|
------------------------------------------------------------------
1 | School | Open | foo | bar | foo |
2 | Office | Open | foo | bar | foo |
3 | School | Done | foo | bar | foo |
4 | Private | Open | foo | bar | foo |
5 | School | Done | foo | bar | foo |


Now I want to look at this data more orderd and I am thinking about a TreeGrid.
The user should choose which column(s) to group by.

For example he groups by "status" he gets



Status
+-OPEN
|--1 | School | foo | bar | foo |
|--2 | Office | foo | bar | foo |
|--4 | Private | foo | bar | foo |
+-DONE
|--3 | School | foo | bar | foo |
|--5 | School | foo | bar | foo |



Maybe even grouping by 2 colums (Category and then status or status and the category).


I know how to use grids and I know how to use TreeGrids, but I do not want to reinvent the wheel or change my data models.

Question 1: What would be the best approach to contert a ListStore to a TreeStore?
Question 2: What would be the best approach to let the user choose which column(s) should be grouped? I thought about a drop down on the colum headers like the one where you can choose the sort order or which colums to display.


Thanks for your input,
schube

Arno.Nyhm
8 Jan 2010, 7:35 AM
maybe a simple grouping is also interesting for you?
http://www.extjs.com/examples/explorer.html#grouping

schube
8 Jan 2010, 8:28 AM
Hi!

Thanks for your hint!

This is a good approach for grouping one field, thanks!

I can work with that for some views and will use it, but for other views I think i really need to group 2 columns, so I will need a TreeGrid I guess.

Any best practice to convert ListStore to TreeStore?

Greetings,
schube