EasyUI Forum

General Category => Bug Report => Topic started by: Pierre on April 13, 2016, 07:30:23 AM



Title: [SOLVED] Drag/Drop and onBeforeLoad
Post by: Pierre on April 13, 2016, 07:30:23 AM
Hello
I have this code::

Code:
	<script type="text/javascript">
var data = [{... some data}]
   function    loadData(){
    $('#aa').treegrid('loadData',data);  
   }
</script>
                
  <!-- Load data button -->
  <a href="#" onclick="loadData();" class="easyui-linkbutton" >Load</a>

<table id="aa" title="Folder Browser" class="easyui-treegrid" style="width:400px;height:400px"
data-options="
animate: true,
idField: 'id',
treeField: 'name',
onBeforeLoad: function(row,data){
$(this).treegrid('enableDnd', row?row.id:null);
}
">
<thead>
<tr>
<th data-options="field:'name'" width="80%">Name</th>
<th data-options="field:'size'" width="10%" align="right">Size</th>
<th data-options="field:'date'" width="10%">Modified Date</th>
</tr>
</thead>
</table>


when I click on "Load" button, data is loaded, but Drag/Drop does not work.
When I use onLoadSuccess instead of onBeforeLoad, it works but then I can not drop on empty treegrid.
Any solution for this - to be able to drop on empty treegrid and to use enableDnd ?
Thank you


Title: Re: Drag/Drop and onBeforeLoad
Post by: jarry on April 13, 2016, 08:32:04 AM
You need to call 'enableDnd' method after creating the empty treegrid, or call this method again after loading data successfully. Please look at this code.
Code:
$('#aa').treegrid({
onLoadSuccess: function(){
$(this).treegrid('enableDnd');
}
});
$('#aa').treegrid('enableDnd');


Title: Re: Drag/Drop and onBeforeLoad
Post by: Pierre on April 13, 2016, 09:53:59 AM
OK solved that, I did not called 'enableDnd' after data loaded, thank you for that, but there is some bug - I attached complete code and image, please do this:
1. Click on Load button to load both treegrid's
2. Click on 'bbb' Tab
3. Click on ** ALL ** record and drag it to 'java.exe' and drop it there.. Where is the record? You can see it if you click on tab 'aaa' - it is there, as last record ...


Title: Re: Drag/Drop and onBeforeLoad
Post by: jarry on April 14, 2016, 12:15:32 AM
Please try to download the patch from http://www.jeasyui.com/download/downloads/jquery-easyui-1.4.5-patch.zip.


Title: Re: Drag/Drop and onBeforeLoad
Post by: Pierre on April 14, 2016, 12:18:54 AM
Hello
just found another bug (it can be reproduced on same source I send in previous post):
1. Click on Load button
2. Select Tab 'bbb'
3. Click once on 'java.exe' (see image below)
4. Click on ***ALL*** record and drag it over 'java.exe' - you will see it is not possible to drop it on 'java.exe'


Title: Re: Drag/Drop and onBeforeLoad
Post by: Pierre on April 14, 2016, 12:22:24 AM
Please try to download the patch from http://www.jeasyui.com/download/downloads/jquery-easyui-1.4.5-patch.zip.

Awesome, this works great, but in the meantime I posted new reply (regarding click on item).
Thank you!


Title: Re: Drag/Drop and onBeforeLoad
Post by: jarry on April 14, 2016, 08:12:51 AM
Please download the updated 'treegrid-dnd.js' file from http://www.jeasyui.com/extension/treegrid_dnd.php


Title: Re: Drag/Drop and onBeforeLoad
Post by: Pierre on April 14, 2016, 09:25:27 AM
Thank you so much, it works perfect.