EasyUI Forum
October 18, 2025, 02:36:03 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: treegrid don't fire onUnSelect, onUnCheck event  (Read 10716 times)
Aod47
Jr. Member
**
Posts: 85


View Profile
« on: June 22, 2015, 09:14:41 PM »

May be I do something wrong, Could you please suggest? Thank you.

Code:
<table title="Folder Browser" class="easyui-treegrid" style="width:700px;height:250px"
data-options="
url: 'treegrid_data1.asp',
method: 'get',
rownumbers: true,
idField: 'id',
treeField: 'name',
singleSelect: false,
selectOnCheck: true,
checkOnSelect: true,
onUnCheck: function(index,row){
console.log(index)
console.log(row)
},
onUnSelect: function(index,row){
console.log(index)
console.log(row)
}
">
<thead>
<tr>
<th data-options="field:'ck',checkbox:true"></th>
<th data-options="field:'id'" width="50">ID</th>
<th data-options="field:'name'" width="220">Name</th>
<th data-options="field:'size'" width="100" align="right">Size</th>
<th data-options="field:'date'" width="150">Modified Date</th>
</tr>
</thead>
</table>
Logged
Aod47
Jr. Member
**
Posts: 85


View Profile
« Reply #1 on: June 22, 2015, 09:51:19 PM »

I found a mistake.  Grin

onUnCheck must be onUncheck
onUnSelect must be onUnselect

Thank you.
Logged
Aod47
Jr. Member
**
Posts: 85


View Profile
« Reply #2 on: June 22, 2015, 10:10:34 PM »

3 days of research. I would like to share a solution that treegrid act like CasecadeCheck of tree control.

But it is not a perfect yet.

Code:
<table id="tg" title="Folder Browser" class="easyui-treegrid" style="width:100%;height:100%;"
data-options="
url: 'treegrid_data1.json',
method: 'get',
rownumbers: true,
idField: 'id',
treeField: 'name',
singleSelect: false,
selectOnCheck: true,
checkOnSelect: true,
onSelect: onSelect,
onUnselect: onUnselect
">
<thead>
<tr>
<th data-options="field:'ck',checkbox:true"></th>
<th data-options="field:'id'" width="50">ID</th>
<th data-options="field:'name'" width="220">Name</th>
<th data-options="field:'size'" width="100" align="right">Size</th>
<th data-options="field:'date'" width="150">Modified Date</th>
</tr>
</thead>
</table>

<script type="text/javascript">
function loopChildren(obj,result) {
obj.forEach( function (arrayItem)
{
var w = arrayItem.id;
result.push(w);
var x = arrayItem.children;
if(x){
loopChildren(x,result);
}
});
return result;
}
function onSelect(data) {
console.log(data.id);
var r = [];
var c = data.children;
if(c){
var s = loopChildren(c,r);
if(s) {
for(var i=0; i<s.length; i++){
var row = s[i];
$("#tg").treegrid('checkRow',row);
}
}
}
}
function onUnselect(data) {
console.log(data.id);
var r = [];
var c = data.children;
if(c){
var s = loopChildren(c,r);
if(s) {
for(var i=0; i<s.length; i++){
var row = s[i];
$("#tg").treegrid('unselectRow',row);
}
}
}
}
</script>   

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!