cancel
Showing results for 
Search instead for 
Did you mean: 

How to get sub-nodes of a node ? (node names)

msevestre
Champ in-the-making
Champ in-the-making
Hello

could somebody indicate me a Javascript methode that mat give me the subnode names when a script in run on a parent directory (not recursive, only first level is asked).

For example, I have a structure:
Parent_Space
|—— SubSpace1
|—— SubSpace2
|—— SubSpace3

I would like to have something that may give me a list of containing the 3 strings "SubSpace1", "SubSpace2" and "SubSpace3" when i execute a script at "Parent_Space" level.

Thanks for any  help !

Regards
Matt
5 REPLIES 5

jayjayecl
Confirmed Champ
Confirmed Champ
See http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook#Iterating_values_using_JavaScript_syntax_for_e...

So, I guess :

var myString = "";for each (child in space.children){   myString += child.name + ";";}‍‍‍‍‍‍‍‍

Then, variable "myString" will hold : "SubSpace1;SubSpace2;SubSpace3;"

msevestre
Champ in-the-making
Champ in-the-making
Hi !

OK, that's working… thanks !

Any way to have only sub spaces ? (currently if I have a document, it is also listed)

Regards
Matt

jayjayecl
Confirmed Champ
Confirmed Champ
var myString = "";for each (child in space.children){if(child.isContainer) {   myString += child.name + ";";}}‍‍‍‍‍‍‍‍‍‍

Hope this helps

msevestre
Champ in-the-making
Champ in-the-making
Thanks !

I think that the topic is now closed Smiley Happy

MAtt

jayjayecl
Confirmed Champ
Confirmed Champ
Sure.
Don't forget to have a look at the wiki.

Everything I wrote was from here :
http://wiki.alfresco.com/wiki/Category:JavaScript_API