EasyUI Forum

General Category => Bug Report => Topic started by: James on November 16, 2015, 01:27:36 AM



Title: Datagrid drag and drop didn't trigger onLoadSuccess
Post by: James on November 16, 2015, 01:27:36 AM
Datagrid drag and drop didn't trigger onLoadSuccess
But Treegrid after drag and drop , onLoadSuccess works


Title: Re: Datagrid drag and drop didn't trigger onLoadSuccess
Post by: jarry on November 16, 2015, 08:46:54 AM
The 'onLoadSuccess' event should not be triggered when drop a node, please use the 'onDrop' event instead. The 'treegrid-dnd.js' file can be downloaded from http://www.jeasyui.com/extension/treegrid_dnd.php


Title: Re: Datagrid drag and drop didn't trigger onLoadSuccess
Post by: James on November 18, 2015, 08:24:05 PM
The 'onLoadSuccess' event should not be triggered when drop a node, please use the 'onDrop' event instead. The 'treegrid-dnd.js' file can be downloaded from http://www.jeasyui.com/extension/treegrid_dnd.php

That's not true. Just try add "console.info('dnd');" to treegrid dnd demo's "onLoadSuccess" function,

http://www.jeasyui.com/extension/downloads/treegrid-dnd.zip

You will find it triggered every time when leaf is droped,

But if you add the same code to datagrid dnd , it will not work as the same way treegrid do.

http://www.jeasyui.com/extension/downloads/datagrid-dnd.zip

In my app, I need to change the display of data after data loaded (can't use formatter, because I need to add params), so I put some code into onLoadSuccess to do the work. treegrid-dnd triggered "onLoadSuccess" every time when data is droped, but datagird did't do it , I don't konw what to do now , I really need it works.


Title: Re: Datagrid drag and drop didn't trigger onLoadSuccess
Post by: jarry on November 18, 2015, 11:44:46 PM
Please use the 'onDrop' event instead.
Code:
$('#dg').datagrid({
onLoadSuccess:function(){
$(this).datagrid('enableDnd');
},
onDrop: function(destRow, sourceRow, point){
console.log('drop ' + sourceRow.itemid + ' on ' + destRow.itemid);
}       
})


Title: Re: Datagrid drag and drop didn't trigger onLoadSuccess
Post by: James on November 19, 2015, 12:42:56 AM
Please use the 'onDrop' event instead.
Code:
$('#dg').datagrid({
onLoadSuccess:function(){
$(this).datagrid('enableDnd');
},
onDrop: function(destRow, sourceRow, point){
console.log('drop ' + sourceRow.itemid + ' on ' + destRow.itemid);
}       
})

if use onDrop instead , that means I should copy the code to onLoadSuccess and onDrop both
Code:
$('#dg').datagrid({
onLoadSuccess:function(){
$(this).datagrid('enableDnd');
                //do something
},
onDrop: function(destRow, sourceRow, point){
//do something
}       
})
while treegrid just need
Code:
$('#dg').treegrid({
onLoadSuccess:function(){
$(this).treegrid('enableDnd');
                //do something
}     
})