Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Insert new Row in the nattable(Insert new Row in the nattable)
Insert new Row in the nattable [message #1724392] Tue, 23 February 2016 15:32 Go to next message
christy jovita is currently offline christy jovitaFriend
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 #1724823 is a reply to message #1724392] Fri, 26 February 2016 11:47 Go to previous messageGo to next message
christy jovita is currently offline christy jovitaFriend
Messages: 22
Registered: June 2014
Junior Member
Can anyone please give an update for this
Re: Insert new Row in the nattable [message #1724824 is a reply to message #1724823] Fri, 26 February 2016 12:00 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
You are not executing a command, you are firing an event. So I don't know what you are doing to insert a row.

You can also ask for professional consulting if you need support.
Re: Insert new Row in the nattable [message #1725144 is a reply to message #1724824] Tue, 01 March 2016 09:10 Go to previous messageGo to next message
christy jovita is currently offline christy jovitaFriend
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

Re: Insert new Row in the nattable [message #1725147 is a reply to message #1725144] Tue, 01 March 2016 09:19 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
It looks like you are not familiar with the Java collections API since you don't change the underlying list.

Therefore:
Quote:
You can also ask for professional consulting if you need support.
Previous Topic:Custom Tree row rendering
Next Topic:MoveSelectionCommand with multiple cells selected
Goto Forum:
  


Current Time: Sat Sep 21 03:55:33 GMT 2024

Powered by FUDForum. Page generated in 0.03345 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top