I have an array of file names/paths. Lets say it contains:
- File1.txt
- Folder1/File2.txt
- Folder1/File3.txt
- Folder2/File4.txt
- Folder3/Folder4/File5.txt
- Folder3/File6.txt
- NewFile.txt
Now I want to create a Dojo Tree which basically displays this information in a tree structure with root as "Files" and below it appears a tree like this
- Files (ROOT)
- File1.txt
- Folder1
- File2.txt
- File3.txt
- Folder2
- File4.txt
- Folder3
- Folder4
- File5.txt
- File6.txt
- Folder4
- NewFile.txt
I was able to create a JSON form single level tree structure. As I am hard pressed for time I need a algorithm/code snippet which can create my desired JSON file. Any ideas!?
Take a look at giveSortedArray() function (yeah I suck at function naming):
http://jsfiddle.net/QDAjz/
I used dojo.store.Memory for easier fetching of existing folders but I'm sure there are some other (possible better) solutions.