PDA

View Full Version : Representation file system tree in TreeGrid



vokunya
26 Jan 2012, 9:31 AM
Hi,
i have a webapp - REST web service
there is a folder with content there, for example:
/path_to_folder/folder
-file1.xsd
-file2.xsd
-subfolder_1
------file1_1.xsd
------subfolder_2
------------subfolder_2_1
------------file_2_1_1
------file_2_1
and so on

and i need to represent that tree in TreeGrid in another gxt webapp.

perhaps, i can do on my ress webapp something like


{
//...

final Collection<File> all = new ArrayList<File>();
addFilesRecursively(new File("path_to_folder/folder"), all);

//....
//send Collection<File> all to gxt webapp
//...
}

private static void addFilesRecursively(File file, Collection<File> all) {
final File[] children = file.listFiles();
if (children != null) {
for (File child : children) {
all.add(child);
addFilesRecursively(child, all);
}
}
}


and i can't to invent an algorithm to represent
Collection<File> all in TreeGrid
any ideas?
or some another problem solution?

thanks

harun
27 Jan 2012, 3:24 AM
Hi Vokunya,

I think your problem is related Basic TreeGrid example. You must look over the sample codes carefully.

http://www.sencha.com/examples/explorer.html#basictreegrid

(http://www.sencha.com/examples/explorer.html#basictreegrid)Especially examine the following lines:




Folder model = TestData.getTreeModel();

TreeStore<ModelData> store = new TreeStore<ModelData>();
store.add(model.getChildren(), true);


You also must look TestData and Folder classes which are coming with GXT source code.

I hope you can solve your problem,
Best Regards,