Is it possible to move items/rows (up and down) inside a table (table, group table, etc.)?
For example:
And it possible make a dnd for items/rows between different tables?
Maybe platform include some listener class or something like that, for handle of intention of transferring data between tables?
I checked example project for dnd ( cuba-dnd ). But creation of Component from code not easier and flexable if need use a table.
I would greatly appreciate for help on this question.
@Inject
private CollectionContainer<Customer> customersDc;
@Inject
private GroupTable<Customer> customersTable;
@Subscribe("upBtn")
public void onUpBtnClick(Button.ClickEvent event) {
Customer selected = customersTable.getSingleSelected();
if (selected != null) {
List<Customer> customers = customersDc.getMutableItems();
int pos = customersDc.getMutableItems().indexOf(selected);
customers.remove(pos);
// need to check index borders
customers.add(pos - 1, selected);
}
customersTable.setSelected(selected);
}
@Subscribe("downBtn")
public void onDownBtnClick(Button.ClickEvent event) {
Customer selected = customersTable.getSingleSelected();
if (selected != null) {
List<Customer> customers = customersDc.getMutableItems();
int pos = customersDc.getMutableItems().indexOf(selected);
customers.remove(pos);
// need to check index borders
customers.add(pos + 1, selected);
}
customersTable.setSelected(selected);
}
Reordering can also be done using Drag and Drop functionality. Sample how to drag and drop between two tables you can find here cuba-labs/sample-table-dragdrop, see OrderEdit screen.
I created actions for the table - to drag rows within the table (like in your example with buttons).
And the example will really help for implementation dnd into project.