PDA

View Full Version : trying to understand async treegrid example



modelka
24 Oct 2011, 1:21 PM
Hi

Q1:

I don't understand where do we print Size and Date in this example http://extjs.com/examples/#asynctreegrid

i.e. who prints "2011 Sep 15 18:22:34" ?

How to modify example to switch Date and Size columns content (so to print date in Size column and to print size in Date column)?

Q2:

How to decide how to parametrize RpcProxy?

I.e. if I declare RpcProxy<List<Sometype>> then I must declare TreeLoader<FileModel> and vice versa?

Thanks

catalin.ciobanu
25 Oct 2011, 12:16 AM
well, you have your FileModel class which has some properties: name, date, size
As you are planning to keep FileModel objects in your tree, you think to have a column for each of it's properties (or at least you want to have some of the properties displayed -> you make a column for each property you want in the treegrid)

So you go creating a "name" column: new ColumnConfig("name", "Name", 100); which will link to the "name" property, will have the header "Name" and will have width 100. You do this for all your displayed properties.


ColumnConfig name = new ColumnConfig("name", "Name", 100);
ColumnConfig date = new ColumnConfig("date", "Date", 100);
ColumnConfig size = new ColumnConfig("size", "Size", 100);

Here you want to display name,date, size so you create the corresponding columns (thru the column config ..)

How to modify example to switch Date and Size columns content
Here you go. Simply modify the header .. and the order, if you want.


ColumnConfig name = new ColumnConfig("name", "Name", 100);
ColumnConfig date = new ColumnConfig("size", "Date", 100);
ColumnConfig size = new ColumnConfig("date", "Size", 100);

Concerning the proxy .. you expect a list of FileModel to load in your treegrid .. so you make a proxy<List<FileModel>>.
Usually the Proxy,Loader,Reader, and your control (grid, tree, treegrid) keep/load/read the same type of data (implementing ModelData) so I'd say YES, you have to declare your TreeLoader<FileModel> , your TreeGrid<FileModel>, and so on.

Hope it helps you a bit ... all the best.

modelka
25 Oct 2011, 3:49 AM
Thank you, I still have several questions.

What is the "property"? Is it just java field?
What properties do "FileModel" has?
Is it possible to check this at design-time?
If so why compiler doesn't report error "certain property doesn't exist"?


ColumnConfig javadoc doesn't use word "property". It use word "id". However it is not clear how this "id" is used to bind column with some field or property...

catalin.ciobanu
25 Oct 2011, 3:59 AM
well you can take a look at FileModel source file within the gxt sdk.
As it has to implement ModelData, it has follow a certain structure .. getters/setters/constructors... well you better take a look at FileModel source file. (go and search for FileModel in the gxt folder, the one extracted from the GXT archive)


If so why compiler doesn't report error "certain property doesn't exist"?
that I don't know :)

modelka
25 Oct 2011, 4:14 AM
i've found FileModel here
http://code.google.com/p/gaedemoiuqrul/source/browse/trunk/gwtSamples/gxtShowcase/src/com/extjs/gxt/samples/client/examples/model/FileModel.java?spec=svn62&r=62 (http://code.google.com/p/gaedemoiuqrul/source/browse/trunk/gwtSamples/gxtShowcase/src/com/extjs/gxt/samples/client/examples/model/FileModel.java?spec=svn62&r=62)

it has "name" and "path" properties, but doesn't has "size" or "date"...

catalin.ciobanu
25 Oct 2011, 4:23 AM
take a look here (http://code.google.com/p/gaedemoiuqrul/source/browse/trunk/gwtSamples/gxtShowcase/src/com/extjs/gxt/samples/server/FileServiceImpl.java?r=62) too.
ModelData acts like a Map(not exactly but this is how I see it) .. you can SET/GET properties .. the id is the name of the property and the value is the value of the field.

FileModel extends BaseModelData .. which implements ModelData so you can put properties. For the FileModel you have some values already defined, and for which you have setter/getter defined. You can add pairs id-value beside those. As long as you need them .. you set them in server and use them in client side .. you can still use them in the other direction as well.

modelka
25 Oct 2011, 6:16 AM
thank you very much.

In the example proxy is parametrized using FileModel: new RpcProxy<List<FileModel>>()
loaded, that use proxy, also parametrized using FileModel: loader = new BaseTreeLoader<FileModel>(proxy)

And this makes sense...

But in my case proxy and loader parametrized using different classes.

proxy is parametrized using some Serializable interface
and loader is parametrized using ModelData.

why and what's the difference between these two approaches?

catalin.ciobanu
25 Oct 2011, 6:21 AM
thank you very much.
But in my case proxy and loader parametrized using different classes.

proxy is parametrized using some Serializable interface
and loader is parametrized using ModelData.


What is your case ? in the gxt explorer async tree example you have the same type FileModel in the proxy and loader

modelka
25 Oct 2011, 6:30 AM
just other private sources I have. the question is how proxy and loader should work if they parametrized using different classes?...