Home » Eclipse Projects » Remote Application Platform (RAP) » Change tree / table header background and foreground color
Change tree / table header background and foreground color [message #1787189] |
Mon, 21 May 2018 12:52  |
Eclipse User |
|
|
|
Hi,
I'm searching a method to change header background / foreground color of tree and table.
Styling header by css is not suitable, because I need to dinamically change background and foreground.
In the latest release of SWT, there are "setHeaderBackground" and "setHeaderForeground".
It's planned to allineate RAP source with SWT source ?
Alternatively, I tried to change color using "JavaScriptExecutor" using code like below, but I can't access to the header id / background method (if exist) :
WidgetRemoteAdapter adapter = ((WidgetRemoteAdapter) tree.getAdapter(RemoteAdapter.class));
String id = adapter.getId(); // header id ??
JavaScriptExecutor service = RWT.getClient().getService(JavaScriptExecutor.class);
service.execute("rap.getObject('" + id + "').setBackground([0,255,0]);");
|
|
| | |
Re: Change tree / table header background and foreground color [message #1787222 is a reply to message #1787189] |
Tue, 22 May 2018 05:48   |
Eclipse User |
|
|
|
Hi Nicola,
CSS styling isn't at all in contrast with dynamic change of background and foreground, even for table headers.
Just define different CSS for your UI status, e.g.
TableColumn {
color: #0000FF;
background-image: gradient(
linear, left top, left bottom,
from( #ff0000 ),
to( #ff0000 )
);
}
TableColumn.other {
color: #00FF00;
background-image: gradient(
linear, left top, left bottom,
from( #0000FF ),
to( #0000FF )
);
}
Then, when you want to change it, do for instance:
TableColumn[] columns = table.getColumns();
columns[2].setData( RWT.CUSTOM_VARIANT, "other" );
it works (just tested)
HTH
Vincenzo
|
|
| |
Re: Change tree / table header background and foreground color [message #1787293 is a reply to message #1787289] |
Wed, 23 May 2018 05:05   |
Eclipse User |
|
|
|
Hi Nicola,
I can assure you that the snippets in my previous post are indeed working, at least if I understood right your needs.
Let me show you.
This is how the table header appears at first

that's because of the base CSS is the following
TableColumn {
color: #0000FF;
background-image: gradient(
linear, left top, left bottom,
from( #ff0000 ),
to( #ff0000 )
);
}
then, when I click on a button, I do this programmatically
TableColumn[] columns = table.getColumns();
columns[3].setData( RWT.CUSTOM_VARIANT, "other" );
and that's what happens immediately

thanks to the following CSS
TableColumn.other {
color: #00FF00;
background-image: gradient(
linear, left top, left bottom,
from( #0000FF ),
to( #0000FF )
);
}
If that's not happening to you, the only reason I can think of is that you aren't handling the ServerPushSession (start/stop). In this case, try to do start it, e.g. when creating the composite, with:
ServerPushSession pushSession = new ServerPushSession();
pushSession.start();
(although at some point you should call also .stop())
Let me know what's not working for you.
HTH
Vincenzo
|
|
| |
Goto Forum:
Current Time: Wed Jul 23 03:41:43 EDT 2025
Powered by FUDForum. Page generated in 0.06580 seconds
|