Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Row selection on cell click
Row selection on cell click [message #1004436] Wed, 23 January 2013 08:28 Go to next message
Mario Prieto is currently offline Mario PrietoFriend
Messages: 9
Registered: January 2013
Junior Member
Hi there!

I'm trying to implement following behavior on the NatTable:

If a user clicks on a rowheader the full row gets selected (nothing special)
If a user clicks on a cell the full row gets selected (special case)

I've tried everything like implementing an own SelectionCommandHandler,
SelectionLayer, etc. how could I get that functionality to work?

Thanks in advance!
Re: Row selection on cell click [message #1004582 is a reply to message #1004436] Wed, 23 January 2013 13:57 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Hi,

that's not a special case. Just use the RowSelectionModel instead of the default SelectionModel. You can see how this works in the Selection_events example:

selectionLayer.setSelectionModel(new RowSelectionModel<RowDataFixture>(selectionLayer, gridLayer.getBodyDataProvider(), new IRowIdAccessor<RowDataFixture>() {

	public Serializable getRowId(RowDataFixture rowObject) {
		return rowObject.getSecurity_id();
	}
			
}));


Greez,
Dirk
Re: Row selection on cell click [message #1004587 is a reply to message #1004582] Wed, 23 January 2013 14:00 Go to previous messageGo to next message
Mario Prieto is currently offline Mario PrietoFriend
Messages: 9
Registered: January 2013
Junior Member
Hi!

Thank you for your reply. I already tried that but the problem is that with that RowSelectionModel when I click on a column all rows get selected even when I don't allow multiple selection.

Best Regards.
Re: Row selection on cell click [message #1004592 is a reply to message #1004587] Wed, 23 January 2013 14:08 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Did you implement the getRowId() correctly? This is needed to identify the row to select by model.

Or do you mean on clicking the column header all rows get selected? Well this is because on clicking at the column header, the default behaviour is to select every cell of that column. And with using the RowSelectionModel of course all rows get selected. If you want to avoid this, you need to disable the selection behaviour on clicking the column header. This can be done by overriding and modifying the DefaultSelectionBindings.configureColumnHeaderMouseClickBindings() method.
Re: Row selection on cell click [message #1004595 is a reply to message #1004592] Wed, 23 January 2013 14:09 Go to previous messageGo to next message
Mario Prieto is currently offline Mario PrietoFriend
Messages: 9
Registered: January 2013
Junior Member
Ok, great! The problem may be on the header behavior...I will give that a try.

Thx again.

[Updated on: Wed, 23 January 2013 14:10]

Report message to a moderator

Re: Row selection on cell click [message #1005071 is a reply to message #1004582] Thu, 24 January 2013 12:22 Go to previous messageGo to next message
Mario Prieto is currently offline Mario PrietoFriend
Messages: 9
Registered: January 2013
Junior Member
Hi!

I have tested after overriding the configureColumnHeaderMouseClickBindings method

and it still selects all rows when I click on the header even if in the model I set multipleSelectionAllowed = false.

Is this a by design so or may it be a bug?

Regards

[Updated on: Thu, 24 January 2013 12:23]

Report message to a moderator

Re: Row selection on cell click [message #1005121 is a reply to message #1005071] Thu, 24 January 2013 14:12 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
How did you override configureColumnHeaderMouseClickBindings()?

I tried this for the Selection_events example by adding this to the RowOnlySelectionBindings (which override DefaultSelectionBindings) and there is nothing selected if I click on the column header:

protected void configureColumnHeaderMouseClickBindings(UiBindingRegistry uiBindingRegistry) {
	//do nothing
}


So I can't see what the issue is in your case.

Greez,
Dirk
Previous Topic:Unregister Keybindings
Next Topic:Invert axis in nattable
Goto Forum:
  


Current Time: Thu Apr 25 03:41:16 GMT 2024

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

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

Back to the top