jQuery EasyUI DataGrid autosave
HTML
<div class="easyui-layout" data-options="fit:true" >
<div data-options="region:'west',split:'true'" style="width:50%">
<h4>Source Tree (non dropable)</h4>
<ul id="sourceTree"></ul>
</div>
<div data-options="region:'center',split:'true'" style="width:50%">
<h4>Target Tree (drop allowed except for Item1)</h4>
<ul id="targetTree"></ul>
</div>
<div/>
CSS
</style> <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css"> <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/demo/demo.css"> <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script> <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.edatagrid.js"></script> <script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-filter.js"></script> <style>
JavaScript
$(function(){
$('#sourceTree').tree({
data: [{text: 'S1',state: 'open',children: [{text: 'S11'},{text: 'S12'}]},{text: 'S2'}],
animate: true,
onlyLeafCheck: false,
lines: true,
dnd: true,
onBeforeDrag: function(source) {
var sourceName = source.text;
console.log("sourceName:"+sourceName);
if(sourceName == 'S1') {
return false;
}
},
onDragOver: function(target, source) { return false; },
onBeforeDrop: function(target, source, point) {return false;}
});
$('#targetTree').tree({
data: [{text: 'T1',state: 'open',children: [{text: 'T11'},{text: 'T12'}]},{text: 'T2'}],
animate: true,
onlyLeafCheck: false,
lines: true,
dnd: true,
onDragOver: function(target, source){
var sourceName = source.text;
if(sourceName == 'S1'){
return false;
}
},
onBeforeDrop: function(target, source, point) {
var targetNode = $(this).tree('getNode', target);
var toAppend = {};
toAppend.id = source.id;
toAppend.text = source.text;
$(this).tree('append', {
parent: target,
data: toAppend
});
$(this).tree('expandAll', target);
return false;
}
});
});