easyui tree帶checkbox實(shí)現(xiàn)單選的簡單實(shí)例
實(shí)例如下:
<ul id="regionTree"></ul>
$('#regionTree').tree({ cascadeCheck: false, //onlyLeafCheck: true, checkbox: true, data: [{ "id": 1, "text": "My Documents", "children": [{ "id": 11, "text": "Photos", "state": "closed", "children": [{ "id": 111, "text": "Friend" }, { "id": 112, "text": "Wife" }, { "id": 113, "text": "Company" }] }, { "id": 12, "text": "Program Files", "children": [{ "id": 121, "text": "Intel" }, { "id": 122, "text": "Java", "attributes": { "p1": "Custom Attribute1", "p2": "Custom Attribute2" } }, { "id": 123, "text": "Microsoft Office" }, { "id": 124, "text": "Games", "checked": true }] }, { "id": 13, "text": "index.html" }, { "id": 14, "text": "about.html" }, { "id": 15, "text": "welcome.html" }] }] , width: 160, height: 32, panelHeight: 400, onSelect: function (node) { var cknodes = $('#regionTree').tree("getChecked"); for (var i = 0; i < cknodes.length; i++) { if (cknodes[i].id != node.id) { $('#regionTree').tree("uncheck", cknodes[i].target); } } if (node.checked) { $('#regionTree').tree('uncheck', node.target); } else { $('#regionTree').tree('check', node.target); } }, onLoadSuccess: function (node, data) { $(this).find('span.tree-checkbox').unbind().click(function () { $('#regionTree').tree('select', $(this).parent()); return false; }); } })
關(guān)鍵代碼:
onSelect: function (node) { var cknodes = $('#regionTree').tree("getChecked"); for (var i = 0; i < cknodes.length; i++) { if (cknodes[i].id != node.id) { $('#regionTree').tree("uncheck", cknodes[i].target); } } if (node.checked) { $('#regionTree').tree('uncheck', node.target); } else { $('#regionTree').tree('check', node.target); } }, onLoadSuccess: function (node, data) { $(this).find('span.tree-checkbox').unbind().click(function () { $('#regionTree').tree('select', $(this).parent()); return false; }); }
以上這篇easyui tree帶checkbox實(shí)現(xiàn)單選的簡單實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
JavaScript檢測瀏覽器是否支持CSS變量代碼實(shí)例
這篇文章主要介紹了JavaScript檢測瀏覽器是否支持CSS變量代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-04-04Javascript動態(tài)綁定事件的簡單實(shí)現(xiàn)代碼
Javascript事件綁定的方法很多,很靈活。不過,作為比較簡單的動態(tài)綁定,下面的代碼看似正確,但得不到預(yù)期的效果。2010-12-12JavaScript實(shí)現(xiàn)帶播放列表的音樂播放器實(shí)例分享
這篇文章主要介紹了JavaScript實(shí)現(xiàn)帶播放列表的音樂播放器實(shí)例分享,包括對播放完歌單之后沒有將要播放的歌曲的提示功能,需要的朋友可以參考下2016-03-03Javascript連接數(shù)據(jù)庫查詢并插入數(shù)據(jù)
這篇文章主要介紹了Javascript連接數(shù)據(jù)庫查詢并插入數(shù)據(jù),下面文章圍繞主題展開詳細(xì)內(nèi)容,具有一的參考價值,需要的小伙伴可以參考一下,希望對你的學(xué)習(xí)有所幫助2022-03-03JavaScript針對網(wǎng)頁節(jié)點(diǎn)的增刪改查用法實(shí)例
這篇文章主要介紹了JavaScript針對網(wǎng)頁節(jié)點(diǎn)的增刪改查用法,實(shí)例分析了JavaScript操作網(wǎng)頁節(jié)點(diǎn)的技巧,非常具有實(shí)用價值,需要的朋友可以參考下2015-02-02