PHP開發架構Yii Framework教程(19) UI 組件 TreeView樣本

來源:互聯網
上載者:User

CTreeView用來顯示具有階層的資料,使用TreeView 通過設定Data屬性。Data為具有下面結構的數組:

ext: string, 樹節點的文本.

expanded: boolean,可選,表示該節點是否展開.

id: string, 可選,該節點ID.

hasChildren: boolean, 可選,預設為False,當為True表示該節點含有子節點.

children: array,可選,子節點數組。.

htmlOptions: array, HTML選項。

到目前為止我們還沒有介紹讀取資料庫,因此本例使用Hard Code的資料如下:

array(       'text' =>  '<a id="27" href="#">World:4</a>' ,       'id' =>  '27' ,       'hasChildren' =>  true,       'children' =>         array       (             array(               'text' =>  '<a id="1" href="#">Europa:3</a>' ,               'id' =>  '1' ,               'hasChildren' =>  true,               'children' =>                 array         (                 array(                     'text' =>  '<a id="3" href="#">Germany:3</a>' ,                     'id' =>  '3' ,                     'hasChildren' =>  true,                     'children' =>                     array                 (                         array(                             'text' =>  '<a id="15" href="#">Munich:0</a>' ,                             'id' =>  '15' ,                             'hasChildren' =>  false,                             ),                         array(                             'text' =>  '<a id="16" href="#">Stuttgart:0</a>' ,                             'id' =>  '16' ,                             'hasChildren' =>  false,                             ),                         array(                             'text' =>  '<a id="5" href="#">Berlin:0</a>' ,                             'id' =>  '5' ,                             'hasChildren' =>  false,                             )                         )),                 array(                     'text' =>  '<a id="2" href="#">Norway:3</a>' ,                     'id' =>  '2' ,                     'hasChildren' =>  true,                     'children' =>                     array                 (                         array(                             'text' =>  '<a id="10" href="#">Stavanger:0</a>' ,                             'id' =>  '10' ,                             'hasChildren' =>  false,                             ),                         array(                             'text' =>  '<a id="12" href="#">Oslo:0</a>' ,                             'id' =>  '12' ,                             'hasChildren' =>  false,                             ),                         array(                             'text' =>  '<a id="11" href="#">Bergen:0</a>' ,                             'id' =>  '11' ,                             'hasChildren' =>  false,                             ))),                 array(                     'text' =>  '<a id="4" href="#">United Kingdom:2</a>' ,                     'id' =>  '4' ,                     'hasChildren' =>  true,                     'children' =>                     array(                                  array(                             'text' =>  '<a id="13" href="#">London:0</a>' ,                             'id' =>  '13' ,                             'hasChildren' =>  false,                             ),                         array(                             'text' =>  '<a id="14" href="#">Manchester:0</a>' ,                             'id' =>  '14' ,                             'hasChildren' =>  false,                             ))),                 array(                     'text' =>  '<a id="7" href="#">Asia:3</a>' ,                     'id' =>  '7' ,                     'hasChildren' =>  true,                     'children' =>                     array                 (                         array(                             'text' =>  '<a id="18" href="#">Japan:0</a>' ,                             'id' =>  '18' ,                             'hasChildren' =>  false,                             ),                         array(                             'text' =>  '<a id="20" href="#">China:0</a>' ,                             'id' =>  '20' ,                             'hasChildren' =>  false,                             ),                         array(                             'text' =>  '<a id="19" href="#">Indonesia:0</a>' ,                             'id' =>  '19' ,                             'hasChildren' =>  false,                             )                         )),                 array(                     'text' =>  '<a id="9" href="#">America:4</a>' ,                     'id' =>  '9' ,                     'hasChildren' =>  true,                     'children' =>                     array                 (                         array(                             'text' =>  '<a id="23" href="#">Canada:0</a>' ,                             'id' =>  '23' ,                             'hasChildren' =>  false,                             ),                         array(                             'text' =>  '<a id="24" href="#">United States:0</a>' ,                             'id' =>  '24' ,                             'hasChildren' =>  false,                             ),                         array(                             'text' =>  '<a id="25" href="#">Mexico:0</a>' ,                             'id' =>  '25' ,                             'hasChildren' =>  false,                             ),                         array(                             'text' =>  '<a id="26" href="#">Argentina:0</a>',                             'id' =>  '26' ,                             'hasChildren' =>  false,                             ))),                 array(                     'text' =>  '<a id="8" href="#">Africa:2</a>' ,                     'id' =>  '8' ,                     'hasChildren' =>  true,                     'children' =>                     array(                                  array(                             'text' =>  '<a id="22" href="#">Kenya:0</a>' ,                             'id' =>  '22' ,                             'hasChildren' =>  false,                             ),                         array(                             'text' =>  '<a id="21" href="#">Tanzania:0</a>' ,                             'id' =>  '21' ,                             'hasChildren' =>  false                             )                         )                     )                 )))));

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.