atributo isOpen en el componente tree


El problema es el siguiente. Queremos que un tree component cargue sus datos de un xml y que saque de este el estado inicial de sus TreeNodes (si estan abiertas o cerradas).

Para hacerlo podríamos implementar una función que recorriera el dataProvider en busca del atributo isOpen y hacer un setIsOpen(true). Pero si modificamos el código del componente resulta algo más sencillo.

En la linea 58 de la clase mx.controls.treeclasses.TreeRow donde pone:


if (branch) {
if (nI==undefined) {
nI = owner.getStyle( (open) ? "folderOpenIcon" : "folderClosedIcon");
} else {

ponemos:


if (branch) {
if (nI==undefined) {
nI = owner.getStyle( (open) ? "folderOpenIcon" : "folderClosedIcon");
}

if (node.attributes.isOpen == "true" && firstTime) {
owner.setIsOpen(node,true,false,false);
firstTime = false;
}
} else {

Donde la variable firstTime es una variable de clase (definida con el resto de variables de la clase) definida como:


var firstTime:Boolean = true;

Ahora podremos utilizar una estructura de xml como la siguiente:

Acordaros que para que los cambios que hagáis en la clase TreeRow afecten al componente que tengas en el fla, teneis que forzar la carga de la clase. Yo simplemente pongo una referencia a ella en el frame 1: mx.controls.treeclasses.TreeRow; Para aseguraros que se está cargando podéis ponerle algun trace de verificación.

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts
COLUMNERO
new code4net();

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!



Bad Behavior has blocked 359 access attempts in the last 7 days.