I welcome!
Whether there are examples drag and drop rows between two tables?
I welcome!
Whether there are examples drag and drop rows between two tables?
I.e., for example, at me two tables - a source and the addressee. It would be desirable to have possibility to shuffle a line between them -
...
Table tableSource = new Table(null, container);
tableSource.setDragMode(TableDragMode.ROW);
tableSource.setDropHandler(new DropHandler() {
public void drop(DragAndDropEvent dropEvent) {
....
}
public AcceptCriterion getAcceptCriterion() {
return null;
}
});
...
Table tableTarget = new Table(null, null);
tableSource.setDragMode(TableDragMode.ROW);
tableSource.setDropHandler(new DropHandler() {
public void drop(DragAndDropEvent dropEvent) {
....
}
public AcceptCriterion getAcceptCriterion() {
return null;
}
});
...
The sampler has an example with a Tree and a Table, you should be able to use that:
example in Sampler
I welcome you, Thomas Mattsson!
Thanks, now I will try to apply the offered decision to a case of two tables.
Unfortunately, in my case this reception will not approach most likely as it is in advance not known, what tables will participate in an exchange of lines, i.e. serializable the class is in advance unknown. Or nevertheless the decision is?
If I understand you correctly, you are trying to implement drag-and-drop between any two tables. For this to work, all table containers need to have the exact same properties (so that you don’t need any mapping between properties) or you need to implement a mapping utility which handles mapping from one table to the other.
In both cases, all tables need to be both drop targets and sources.
I welcome you, Thomas Mattsson!
Many thanks for the answer!
i too need for drag and drop beween two tables if any one have samples please post me,
Holas! aquí tienen lo que hice para el
drag and drop
entre dos tablas:
package com.example.tabletable;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.event.DataBoundTransferable;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.ui.AbstractSelect.AcceptItem;
import com.vaadin.ui.Table.TableDragMode;
public class dsgTablesView extends dsgTables {
/**
*
*/
private static final long serialVersionUID = 1L;
final BeanItemContainer tableContainerIzq = new BeanItemContainer(ctablas.class);
final BeanItemContainer tableContainerDer = new BeanItemContainer(ctablas.class);
public void dataTbIzq() {
tableContainerIzq.addItem(new ctablas("Paul","Sanchez"));
tableContainerIzq.addItem(new ctablas("Gina","Villegas"));
tbIzq.setContainerDataSource(tableContainerIzq);
tbIzq.setImmediate(true);
tbIzq.setSelectable(true);
tbIzq.setDragMode(TableDragMode.ROW);
}
public void dataTbDer() {
tableContainerDer.addItem(new ctablas("Juan","Perez"));
tableContainerDer.addItem(new ctablas("Rosa","Lopez"));
tbDer.setContainerDataSource(tableContainerDer);
tbDer.setImmediate(true);
tbDer.setSelectable(true);
tbDer.setDragMode(TableDragMode.ROW);
}
public void dropIzq() {
tbIzq.setDropHandler(new DropHandler() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public AcceptCriterion getAcceptCriterion() {
return AcceptItem.ALL;
}
@Override
public void drop(DragAndDropEvent dropEvent) {
final DataBoundTransferable t = (DataBoundTransferable)dropEvent.getTransferable();
Object ItemId = (Object)t.getItemId();
tableContainerIzq.addItem(ItemId);
tableContainerDer.removeItem(ItemId);
}
});
}
public void dropDer() {
tbDer.setDropHandler(new DropHandler() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public AcceptCriterion getAcceptCriterion() {
return AcceptItem.ALL;
}
@Override
public void drop(DragAndDropEvent dropEvent) {
final DataBoundTransferable t = (DataBoundTransferable)dropEvent.getTransferable();
Object ItemId = (Object)t.getItemId();
tableContainerDer.addItem(ItemId);
tableContainerIzq.removeItem(ItemId);
}
});
}
}
Considerar, que se utilizó un constructor ctablas de la clase ctablas y Vaadin Designer para agregar dos tablas “TabletableUI”. Adjunto todos los archivos del proyecto.
Saludos!
20819.java (781 Bytes)
20820.java (712 Bytes)
20821.java (499 Bytes)
20822.java (2.37 KB)