SmartClient Version: SNAPSHOT_v8.3d_2012-07-03/PowerEdition Deployment (built 2012-07-03)
I have two ListGrids with drag&drop enabled. I implemented the onRecordDrop where I want to use my own drop behaviour.
Now when dropping a record onto an already existing one, everything works as expected:
event.getTargetRecord() gives me the target record with all its attributes.
When I drop the record onto an empty space in the ListGrid, I would expect that event.getTargetRecord() == null. But in this case I also get a record returned with no attributes at all. Doing then something like event.getTargetRecord().getAttributes() causes JavascriptExceptions.
Furthermore, even if I call event.cancel() as first statement in onRecordDrop(), after having the mentioned error an add operation is automatically performed.
Standalone Testcase:
I have two ListGrids with drag&drop enabled. I implemented the onRecordDrop where I want to use my own drop behaviour.
Now when dropping a record onto an already existing one, everything works as expected:
event.getTargetRecord() gives me the target record with all its attributes.
When I drop the record onto an empty space in the ListGrid, I would expect that event.getTargetRecord() == null. But in this case I also get a record returned with no attributes at all. Doing then something like event.getTargetRecord().getAttributes() causes JavascriptExceptions.
Furthermore, even if I call event.cancel() as first statement in onRecordDrop(), after having the mentioned error an add operation is automatically performed.
Standalone Testcase:
Code:
public class Showcase implements EntryPoint { public void onModuleLoad() { ListGrid lgDragOut = new ListGrid(); lgDragOut.setDataSource(DataSource.get("countryDS")); lgDragOut.setCanDragRecordsOut(true); lgDragOut.setDragDataAction(DragDataAction.COPY); lgDragOut.setAutoFetchData(true); ListGrid lgAnimals = new ListGrid(); lgAnimals.setDataSource(DataSource.get("animals")); lgAnimals.setCanAcceptDroppedRecords(true); lgAnimals.setAutoFetchData(true); lgAnimals.setWidth("50%"); lgAnimals.addRecordDropHandler(new RecordDropHandler() { @Override public void onRecordDrop(RecordDropEvent event) { event.cancel(); if (event.getTargetRecord() == null) { SC.say("target record is null"); } else { SC.say("target record is " + event.getTargetRecord().getAttribute("Animal")); } } }); HLayout main = new HLayout(); main.setWidth100(); main.setHeight100(); main.addMember(lgAnimals); main.addMember(lgDragOut); main.draw(); } }
Comment