Help with CTreeView persist : location on CRUD views

Hello All,

I’m facing an issue with the CTreeView persist option when set to “location” for CRUD views.

The situation is this: when I choose a tree opion that renders a controller action page it puts the "selected" class on the tree option, right as I need:

[center]6487

img1.png

The $data code is:




$dataTree=array(

    array(

	'text'=>'Inventario',

	'children'=>array(

	array('text'=>'<a href="/localhost/inventario/articulos">Art&iacute;culos</a>'),

	array('text'=>'<a href="/localhost/inventario/grparticulos">Grupo de art&iacute;culos</a>'),

	array('text'=>'<a href="/localhost/inventario/categweb">Categor&iacute;as Web</a>'),

	)

    )

);



The trouble comes when I go to a different accion of the same controller, for example the “create” action /localhost/inventario/articulos/create. In this case, the CTreeView expands all and no item gets the “selected” class. I’d need the CTreeView path /localhost/inventario/articulos to have the “selected” class on, not only for when it is active, but also for its children like .../create, .../update, .../view.

How can I achieve that?

Thanks for your help.

It looks like "persist" is only there to provide a quick way to save the state of your tree. "Location" looks at the javascript "location.href" value and expands the tree item that contains the exact same link. Any variation to the link like different action names or GET values will throw it off.

You might have to stop using that and instead cook up some logic by reading controller/action names and using the "expanded" key for each entry to make your tree follow your controller setup.

Thanks a lot for your comment. I’ve sorted it out by writing a different logic to the tree.

Alejandro.