TreeView Checkbox选中
生活随笔
收集整理的這篇文章主要介紹了
TreeView Checkbox选中
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
代碼 <script?language='javascript'?type='text/javascript'>
????????$(document).ready(function()?{
????????????var?$checkBox?=?$(':checkbox');
????????????$checkBox.click(function()?{
????????????var?value?=?$(this).attr('checked');
????????????child($(this),?value);
????????????parent($(this),?value);
????????????});
????????});
????????function?parent(obj,value)?{
????????????var?$obj?=?obj;
????????????var?$div?=?$obj.closest('div');
????????????var?$parent?=?$div.prev('table');
????????????if?(!value)?{
????????????????if?($div.children('table').find(':checkbox:checked').length?==?0)
????????????????????$parent.find(':checkbox').attr('checked',?value);
????????????}?else?{
????????????????$parent.find(':checkbox').attr('checked',?value);
????????????}
????????????if?($parent.length?>?0)
????????????????parent($parent,?value);
????????}
????????function?child(obj,value)?{
????????????var?$obj?=?obj;
????????????var?$table?=$obj.closest('table');
????????????var?$div?=$obj.closest('div');
????????????var?$children?=?$table.next('div');
????????????if?($children.length?>?0)?{
????????????????$children.find(':checkbox').attr('checked',?value);
????????????}
????????}
????????
????</script> ? 此腳本 很好用 選中父節點 子節點全部選中, 選擇子節點 對應的父節點也選中 Treeview1 的屬性 ShowCheckBoxes="All" ?
????????$(document).ready(function()?{
????????????var?$checkBox?=?$(':checkbox');
????????????$checkBox.click(function()?{
????????????var?value?=?$(this).attr('checked');
????????????child($(this),?value);
????????????parent($(this),?value);
????????????});
????????});
????????function?parent(obj,value)?{
????????????var?$obj?=?obj;
????????????var?$div?=?$obj.closest('div');
????????????var?$parent?=?$div.prev('table');
????????????if?(!value)?{
????????????????if?($div.children('table').find(':checkbox:checked').length?==?0)
????????????????????$parent.find(':checkbox').attr('checked',?value);
????????????}?else?{
????????????????$parent.find(':checkbox').attr('checked',?value);
????????????}
????????????if?($parent.length?>?0)
????????????????parent($parent,?value);
????????}
????????function?child(obj,value)?{
????????????var?$obj?=?obj;
????????????var?$table?=$obj.closest('table');
????????????var?$div?=$obj.closest('div');
????????????var?$children?=?$table.next('div');
????????????if?($children.length?>?0)?{
????????????????$children.find(':checkbox').attr('checked',?value);
????????????}
????????}
????????
????</script> ? 此腳本 很好用 選中父節點 子節點全部選中, 選擇子節點 對應的父節點也選中 Treeview1 的屬性 ShowCheckBoxes="All" ?
?
轉載于:https://www.cnblogs.com/wanglinglong/archive/2010/03/22/1691758.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的TreeView Checkbox选中的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Web 设计中的苹果风
- 下一篇: 知识在于积累和分类,厚积薄发