Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Jigar Jain on Apr 20, 2009 10:02
open dhtmlx forum
drag and drop column

Hello,

Can I drag and drop one column from a grid to treegrid, which updates only the column of tree grid.
It should not create another child inside the tree grid but should only update the database.

Thanks.
Answer posted by Support on Apr 21, 2009 05:32
You can use onDrag event to change the logic of d-n-d ( set new value instead of adding new row ), and use dataprocessor or any other way to save result data in DB

grid.attachEvent("onDrag",function(sid,tid,sgrid,tgrid){
        if (sgrid != tgrid){ //draged from different grid
                  tgrid.cells(tid,0).setValue(sgrid.cells(sid,0).getValue());
                 //if dataprocessor used - mark as updated
                 // dp.setUpdated(tid,true);
        }
        return false;
})
Answer posted by Jigar Jain on Apr 22, 2009 11:24
Is there anyway I can figure out the column name or Id of the target grid where the row was dropped from the source grid.
Answer posted by Support on Apr 23, 2009 05:24
Actually onDrag event provides 6 parameters, I just skiped two last in previous sample, so the same code can be used as

grid.attachEvent("onDrag",function(sid,tid,sgrid,tgrid,sindex,tindex){
....

sindex -index of column from which drag started
tindex - index of column on which drop occurs

You can convert column indexes to column names or IDs ( if they was defined ) by grid's API