easyui的treegrid的級聯勾選子節點,或者級聯勾選父節點
級聯勾選子節點:
第一種:級聯勾選子節點(父節點級聯子節點)
步驟:
1.在treegrid的onCheck(選中)事件中寫上函式(級聯勾選子節點):
onCheck : function(row){
t = $(this);
opts = t.treegrid("options");
if (opts.checkOnSelect && opts.singleSelect) { return; }
var idField = opts.idField, id = row[idField], children, checked, parent = row;
//如果當前節點被勾選,那麼勾選該節點的子節點
$.each(t.treegrid("getChildren", id), function (i, n) {
if (!t.treegrid("isChecked", n[idField])) { t.treegrid("check", n[idField]); }
});
},
2.在onUncheck(取消選中)事件中寫上函式(級聯取消勾選子節點):
t = $(this);
opts = t.treegrid("options");
if (opts.checkOnSelect && opts.singleSelect) { return; }
var idField = opts.idField, id = row[idField], children, checked, parent = t.treegrid("getParent", id);
$.each(t.treegrid("getChildren", id), function (i, n) {
t.treegrid("uncheck", n[idField]);
});
第二種:級聯勾選父節點(子節點級聯父節點)
onCheck事件:
onCheck : function(row){
t = $(this);
opts = t.treegrid("options");
if (opts.checkOnSelect && opts.singleSelect) { return; }
var idField = opts.idField, id = row[idField], children, checked, parent = t.treegrid("getParent", id);
while (parent) {
children = t.treegrid("getChildren", parent[idField]);
checked = t.treegrid("getChecked");
if (!$.array.some(children, function (val) { return !$.array.contains(checked, val); })) {
if (!t.treegrid("isChecked", parent[idField])) { t.treegrid("check", parent[idField]); }
}
parent = t.treegrid("getParent", parent[idField]);
}
$.each(t.treegrid("getChildren", id), function (i, n) {
//如果子節點沒有勾選,那麼勾選子節點
if (!t.treegrid("isChecked", n[idField])) { t.treegrid("check", n[idField]); }
});
}
onUncheck事件:
onUncheck:function(row){
t = $(this);
opts = t.treegrid("options");
if (opts.checkOnSelect && opts.singleSelect) { return; }
var idField = opts.idField, id = row[idField], children, checked, parent = t.treegrid("getParent", id);
while (parent) {
children = t.treegrid("getChildren", parent[idField]);
checked = t.treegrid("getChecked");
if (!$.array.some(children, function (val) { return $.array.contains(checked, val); })) {
if (t.treegrid("isChecked", parent[idField])) { t.treegrid("uncheck", parent[idField]); }
}
parent = t.treegrid("getParent", parent[idField]);
}
$.each(t.treegrid("getChildren", id), function (i, n) {
t.treegrid("uncheck", n[idField]);
});
}
相關文章
- Ant Design Vue Tree 選中子節點同時半選中父級節點Vue
- json 陣列已知父節點,求所有子節點JSON陣列
- 資料庫——查詢樹形結構某節點的所有子節點、所有父節點資料庫
- C#實現的下拉多選框,下拉多選樹,多級節點C#
- JavaScript學習之DOM(節點、節點層級、節點操作)JavaScript
- ztree 篩選選中節點
- JQuery2:節點選取與節點插入jQuery
- PyQt5 之勾選選單QT
- 重磅 | 首個企業級社群Wancloud宣佈競選EOS超級節點Cloud
- QListWidget項新增勾選框
- 1.19 JQuery2:節點插入與節點選取jQuery
- EOS超級節點競選首個企業級社群!Wancloud滿分入圍!Cloud
- 樹,計算父節點的值
- 【vue】在二叉樹中根據子節點找出父節點路徑Vue二叉樹
- 點選 Button觸發事件將GridView1 CheckBox勾選的行新增到GridView2中事件View
- WPF TreeView級聯複選View
- Python-SQLAlchemy:第4節:級聯PythonSQL
- 過濾/篩選樹節點
- openGauss-指定節點升級
- React計算antd的TreeSelect元件所選中的子節點數量React元件
- 與 Rust 勾心鬥角 · 點Rust
- JavaScript 省市級聯選單原理JavaScript
- jquery實現四級級聯下拉選單jQuery
- WPF DataGrid開箱即用支援全部勾選的DataGridCheckBoxColumn
- Elasticsearch 節點選舉和primary分片Elasticsearch
- Java中在二叉搜尋樹中查詢節點的父節點Java
- TKE 超級節點,Serverless 落地的最佳形態Server
- 使用json和jquery級聯選擇JSONjQuery
- dom4j 根據xml節點路徑查詢節點,找到對應的目標節點下的子節點,對節點Text值進行修改XML
- 鏈塔智庫:資料解讀EOS超級節點大選(附下載)
- kubernetes 加入子節點
- CSS父級選擇器 :has()CSS
- 【許曉笛】EOS 超級節點的五個使命
- vue中在父元件點選按鈕觸發子元件的事件Vue元件事件
- JavaScript獲取父元素下子元素節點JavaScript
- Winform 工具欄 ToolStripMenuItem下拉選擇項選中對勾不居中ORMUI
- XML文件節點導航與選擇指南XML
- 引力資本加入鏈改超級節點