How to deselect the current row of a table ?

Hi there,

Simple question this time :wink:

Let’s say I’ve a button and a table.
The user selects a row by clicking in the table and the row is highlighted as the current row.

Then the user clicks the button. In the ClickListener of the button, I’d like to deselect the current row, so the table appears as if the user had not clicked the table yet.

I tried table.setValue(null) in the button’s ClickListener but with no success.

Has anybody a better suggestion?

Thanks.
John.

have you tried table.select(null) ?

Thank you Jens, select(null) works.
In fact, setValue(null) works too: I was wrong.

John.

Hi there,

There is something I must miss here…

here is my implementation of ItemClickListener.itemClick:

	public void itemClick(ItemClickEvent event) {
		boolean modifier = event.isCtrlKey() || event.isShiftKey();
		if (!modifier){
			((Table)event.getSource()).setValue(null);
			((Table)event.getSource()).select(event.getItemId());
		}
	}

i.e. if the user does not press SHIFT or CTRL when clicking on a row, I want to deselect all.
I tried both suggestions (table.select(null) or table.setValue(null)), but the table rows remain selected.

In debug mode, I see that setValue is properly executed, but the selection is restored after that by a call from CommunicationManager.handleVariables.

Any hint on this ?

Damien

The ‘normal’ select probably occurs after itemClick; i.e using ‘normal’ selection and itemClick for selection at the same time might cause problems.

Try setSelectable(false) and handle selections w/ itemClick instead.

Best Regards,
Marc

So simple… and it worked !
Thanks a lot Marc !