Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » how to hide multiple Columns in Nattable
how to hide multiple Columns in Nattable [message #1725717] Mon, 07 March 2016 09:23 Go to next message
Rashmi Tr is currently offline Rashmi TrFriend
Messages: 22
Registered: November 2011
Junior Member
In my Nattable I have several Column Groups. In every Column Group there are Columns with same name like:

------------------ Person1 --------------- |------------- Person2 --------------------
Name | Age | Gender | Married | Name | Age | Gender | Married

So, with right click on a column (say Age) and selecting Menu Hide Column, all columns with the same name in every Column Groups should be hidden
i.e all the Column 'Age' will be hidden from every Person Group.

My Question is, is it possible to do so in Nattable and if yes how?

I have written below code for Hide Column Menu:

.withMenuItemProvider(new IMenuItemProvider() {

@Override
public void addMenuItem(NatTable natTable, Menu popupMenu) {
columnHideItem = new MenuItem(popupMenu, SWT.PUSH);
columnHideItem.setText("Hide Column");
columnHideItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int columnPosition = MenuItemProviders.getNatEventData(event).getColumnPosition();
natTable.doCommand(new ColumnHideCommand(natTable, columnPosition));
}
});
}
})

Thanks a lot in advance.
Re: how to hide multiple Columns in Nattable [message #1725722 is a reply to message #1725717] Mon, 07 March 2016 10:00 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Use the MultiColumnHideCommand
Re: how to hide multiple Columns in Nattable [message #1726478 is a reply to message #1725722] Mon, 14 March 2016 09:12 Go to previous messageGo to next message
Rashmi Tr is currently offline Rashmi TrFriend
Messages: 22
Registered: November 2011
Junior Member
Hallo Dirk,
Thanks for your reply. Today I tried with MultiColumnHideCommand.
The columns are hidden from the column groups which are visible to the screen only.But column in the column groups which will be visible after scrolling are not hidden. What will be the reason for that and what should be done to hide them as well?

Thanks and regards,
Rashmi
Re: how to hide multiple Columns in Nattable [message #1726488 is a reply to message #1726478] Mon, 14 March 2016 09:49 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
In that case you need to use the API of the ColumnHeaderLayer directly, because the commands are currently only position based, and therefore you get the described behavior.

Or create a handler that is able to deal with indexes.
Re: how to hide multiple Columns in Nattable [message #1726503 is a reply to message #1726488] Mon, 14 March 2016 10:48 Go to previous messageGo to next message
Rashmi Tr is currently offline Rashmi TrFriend
Messages: 22
Registered: November 2011
Junior Member
Hi Dirk,
thanks for your quick response. Using the ColumnHideShowLayer worked out for me.
columnHideShowLayer.hideColumnPositions(columnsToHide);
Re: how to hide multiple Columns in Nattable [message #1726908 is a reply to message #1726503] Thu, 17 March 2016 11:57 Go to previous messageGo to next message
Rashmi Tr is currently offline Rashmi TrFriend
Messages: 22
Registered: November 2011
Junior Member
Hi Dirk,
above Solution which I mentioned is working fine except in one case. Aftre scrolling when I am hiding a column(with right click on a column) all the columns which are in column groups after that column are hidden even if they are not visible to the screen but not the columns which are in previous column groups and not visible to the screen. So I think I should go for the solution that deals with Indexes.

If I write Handler for Indexes, still I need some mechanism to Hide Columns through Index. I see in ColumnHideShowLayer method to hide Columns with positions.
Can you please help me how I should go further.
Re: how to hide multiple Columns in Nattable [message #1727002 is a reply to message #1726908] Fri, 18 March 2016 08:05 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
1. If you have issues on scrolling, there is an issue with the position-index transformation in your logic. Probably you need to extend the ColumnHideShowLayer as the API is not consistent at the moment. I think there was a forum post some days ago regarding this.
2. You might also want to check if your layer composition matches the one in our examples. Not sure if you face another issue.
Re: how to hide multiple Columns in Nattable [message #1727007 is a reply to message #1727002] Fri, 18 March 2016 09:04 Go to previous message
Rashmi Tr is currently offline Rashmi TrFriend
Messages: 22
Registered: November 2011
Junior Member
Hi Dirk,
I extended the ColumnHideShowLayer as one forum post regarding this and it is working right now...If I will get any problem later then I will definetly let you know.

Many Thanks,
Rashmi
Previous Topic:How to get the Copy data of a editable cell
Next Topic:Bug or wanted behavior: selectAll
Goto Forum:
  


Current Time: Fri Apr 26 03:48:41 GMT 2024

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

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

Back to the top