Insert new Row in the nattable [message #1724392] |
Tue, 23 February 2016 15:32 |
christy jovita Messages: 22 Registered: June 2014 |
Junior Member |
|
|
I am trying to insert a new row in between two rows in the table.
I have tried using the following command. But it doesnt work.
Am I missing something or Please suggest me any ideas
dataLayer.fireLayerEvent(new RowInsertEvent(dataLayer, 5));
nattable.refresh();
[Updated on: Tue, 23 February 2016 15:32] Report message to a moderator
|
|
|
|
|
Re: Insert new Row in the nattable [message #1725144 is a reply to message #1724824] |
Tue, 01 March 2016 09:10 |
christy jovita Messages: 22 Registered: June 2014 |
Junior Member |
|
|
Hi Dirk,
As you have mentioned I created the command for inserting the row. and executing it.
public class AddRowCommand extends AbstractRowCommand {
public AddRowCommand(ILayer layer, int rowPosition) {
super(layer, rowPosition);
}
protected AddRowCommand(AddRowCommand command) {
super(command);
}
@Override
public ILayerCommand cloneCommand() {
return new AddRowCommand(this);
}
}
public class AddRowCommandHandler<CellItem> implements ILayerCommandHandler<AddRowCommand> {
private List<CellItem> bodyData;
public AddRowCommandHandler(List<CellItem> bodyData) {
this.bodyData = bodyData;
}
@Override
public Class<AddRowCommand> getCommandClass() {
return AddRowCommand.class;
}
@Override
public boolean doCommand(ILayer targetLayer, AddRowCommand command) {
//convert the transported position to the target layer
if (command.convertToTargetLayer(targetLayer)) {
//the changed dataprovider with newly inserted element
dataLayer.setDataProvider(bodyDataProvider);
//fire the event to refresh
dataLayer.fireLayerEvent(new RowInsertEvent(dataLayer, command.getRowPosition()));
return true;
}
return false;
}
}
and I am executing the following the command in a button for inserting the row.
natTable.doCommand(new AddRowCommand(dataLayer, 1));
and have also registered the command handler
dataLayer.registerCommandHandler(new AddRowCommandHandler(group)) ; // group contains list of items in the table
In my table there are two rows present already and I want to insert a new row in the second position and move the row present already in the second position to the third position.
After executing the command, there is no change.
What am I missing here? Could you please suggest any ideas.
P.S I am not using GlazedLists.
Thanks
[Updated on: Tue, 01 March 2016 09:16] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03345 seconds