Title: treegrid don't fire onUnSelect, onUnCheck event
Post by: Aod47 on June 22, 2015, 09:14:41 PM
May be I do something wrong, Could you please suggest? Thank you. <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>
Title: Re: treegrid don't fire onUnSelect, onUnCheck event
Post by: Aod47 on June 22, 2015, 09:51:19 PM
I found a mistake. ;D
onUnCheck must be onUncheck onUnSelect must be onUnselect
Thank you.
Title: Re: treegrid don't fire onUnSelect, onUnCheck event
Post by: Aod47 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. <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>
|