Yii Framework Forum: Ctreeview Doesn't Use Htmloptions In Data - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ctreeview Doesn't Use Htmloptions In Data Rate Topic: ***** 1 Votes

#1 User is offline   realtebo 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 633
  • Joined: 03-October 12
  • Location:Ferrara

Posted 22 November 2012 - 04:52 AM

Simple way to reproduce

When creating tree for a CTreeView I'm doing a for whit this insidee
$outChildren[] = array('id' => $childData->companyChildId."_companyChildId",
                                   
                                  'text' => $text, 
                                  'hasChildren' => true,
                                  'htmlOptions' => array(
                                          'class' => 'trapForBug',
                                          'data-role' => 'anotherTrap',
                                   ),
                   
                                  );



When rendered, the UL has not the class setted, and has not the 'data-role' attribute setted.

I see in documentation that CTreeView has htmlOptions for itself, but inside the data is possible to set htmlOptions for every item.

Quote

data property
public array $data;

the data that can be used to generate the tree view content. Each array element corresponds to a tree view node with the following structure:

text: string, required, the HTML text associated with this node.
expanded: boolean, optional, whether the tree view node is expanded.
id: string, optional, the ID identifying the node. This is used in dynamic loading of tree view (see url).
hasChildren: boolean, optional, defaults to false, whether clicking on this node should trigger dynamic loading of more tree view nodes from server. The url property must be set in order to make this effective.
children: array, optional, child nodes of this node.
htmlOptions: array, additional HTML attributes (see CHtml::tag). This option has been available since version 1.1.7.

Note, anything enclosed between the beginWidget and endWidget calls will also be treated as tree view content, which appends to the content generated from this data.




Follow a tipical json data which NOT render the htmlOptions in the leaf
[
{"id":"3_companyChildId",
 "text":"Terza azienda",
 "hasChildren":true,
 "htmlOptions":{"class":"trapForBug","data-role":"anotherTrap"}
}, 
.... 
]

Il computer non ragiona, ma ha sempre ragione.
Ricordalo quando fai il debug
0

#2 User is offline   Tiborius 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 18-March 13

Posted 11 May 2013 - 08:48 PM

You can not use htmlOptions in treeview async ajax calls. Only the 'classes' of the leaf can be specified in the json response:

[
{"id":"3_companyChildId",
 "text":"Terza azienda",
 "hasChildren":true,
 "classes":"trapForBug"
}, 
.... 
]

Optionally you can modify the framework/web/js/source/jquery.treeview.async.js script to process other leaf attributes or even htmlOptions.
0

#3 User is offline   realtebo 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 633
  • Joined: 03-October 12
  • Location:Ferrara

Posted 13 May 2013 - 12:24 AM

Thanks for reply, but I cannot understand why it's in the documentation if it's not an available option !
Il computer non ragiona, ma ha sempre ragione.
Ricordalo quando fai il debug
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users