2011-10-01 217 views
0

我有一個使用jQuery的複選框樹。下面是tree_data.json代碼:jQuery複選框樹選擇

[{ 
"id":1, 
"text":"Administrator", 
"children":[{ 
    "id":2, 
    "text":"Cpanel", 
    "state":"open", 
    "children":[{ 
     "id":3, 
     "text":"Activator", 
     "state":"closed", 
      "children":[{ 
       "text":"Delete" 
       },{ 
       "text":"Edit" 
       },{ 
       "text":"New" 
       },{ 
       "text":"View" 
         }] 
       }] 
     }] 
    }] 

和看法是這樣的

<table border="1" width="500"><tr><td> 
<ul id="tt" class="easyui-tree" url="data/tree_data.json" checkbox="true"> 
</ul> 
</td></tr> 
<tr><td>Your selected role are : </td></tr> 
</table> 
<table><tr><td>Your selected role are <input type="text" /></td></tr></table> 

輸出爲我的看法是這樣的:

[]Administrator 
    []Cpanel 
    []Activator 
     []Delete 
     []Edit 
     []New 
     []View 

我想問如何獲取我的複選框值。

例如:如果我檢查 「刪除」 和 「編輯」,然後

你選擇的角色有: 「Activator_Delete」, 「Activator_Edit」

感謝您的幫助

編輯

我是新來使用jQuery,所以請幫助我給我一些例子,而不是鏈接

感謝

回答

0

使用easyui樹的getChecked方法:

var nodes = $('#tt').tree('getChecked'); 

Here's the .tree method list

+0

謝謝格雷厄姆,但你能舉一些例子嗎?即時通訊新的使用jQuery。 –