Register here!

Forgot password?

ASK NEW QUESTION

Home Page » Zii » List View » RenderPartial w/ CTreeView & CListView
0 Votes
Vote Con!
Solved!

RenderPartial w/ CTreeView & CListView

CListViewCTreeViewrenderPartial

Hello all,

I’m currently using a CtreeView (as leftside menu) w/ links on each of the elements.
Links are “…/controler/action?elemento=4″
Where elemento is category items wanting to display.

In the middle is a listView which show items by categories.

IE.
empty(elemento) –> show all category items
elemento=1 –> show items which have category 1

But when I click left side links (it takes me to the correct page) but the CTreeView colapses & looses it’s current open hierarchy state.

I am thinking of 1 of 2 ways to so solve this:
1.- pass a parameter in URL to set the ctreeview lastState. How?
2.- renderPartial (ClistView) on click of CTreeView

In controller I have

  1.         if(isset($_GET['elemento'])){
  2.  
  3.             $this->renderPartial('clistView',array('dataProvider'=>$dataProvider),true,false);
  4.         }
		if(isset($_GET['elemento'])){

			$this->renderPartial('clistView',array('dataProvider'=>$dataProvider),true,false); 
		} 

in View

  1. ...
  2. echo $this->renderPartial('clistView',array('dataProvider'=>$dataProvider));
  3. ...
  4.                 $this->widget('CTreeView',array(
  5.                     'id'=>'menu-treeview',
  6.                     'url' => array('ajaxFillTree'), )) ;
  7. ...
...
echo $this->renderPartial('clistView',array('dataProvider'=>$dataProvider)); 
...
				$this->widget('CTreeView',array(
				    'id'=>'menu-treeview',
				    'url' => array('ajaxFillTree'), )) ;
...

I do not have a grasp on what renderPatial Vs. render does. And does this help w/ my current problem.

Thanks

By tuolden in List View · Asked 579 days 10 hours 22 mins ago

Questions: 25 Accepted: 0 ( 0% ) | Reputation: 0

 

Answers (2)

  1. 0 votes
    Accepted

    I think your second option is best so you do not have to duplicate tree rendering on each tree node call. I assume that the second option is an AJAX call, thus renderPartial is echoing just that part that you need to render without the header and footer of layouts.

    From yiiframework about renderPartial:

    This method differs from render() in that it does not apply a layout to the rendered result. It is thus mostly used in rendering a partial view, or an AJAX response

    By tonydspaniard · 579 days 10 hours 4 mins ago

    Questions: 2 Accepted: 0 ( 0% ) | Reputation: 0

  2. 0 votes

    Great…

    The solution for anyone else was to create a new action for the controller

    IE. actionUpdateAjax

    At the end …

    this->renderPartial(‘element’, array(‘dataProvider’=>$dataProvider,) , false, true);

    For more information please look at here

    By tuolden · 578 days 13 hours 34 mins ago

    Questions: 25 Accepted: 0 ( 0% ) | Reputation: 0

© YiiAnswers.com 2011. All rights reserved.

Switch to our mobile site