Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to change the cell background color?
How to change the cell background color? [message #1516798] Fri, 19 December 2014 04:06 Go to next message
Srinivas Umareddy is currently offline Srinivas UmareddyFriend
Messages: 4
Registered: December 2014
Junior Member
I created editable Natable with combo and text editor. I am not able to find the approach to change the cell backgroud color based on the editable rule.

When the cell is not editable then i need to change the cell background color form white to gray color.

Is there anyway to get the isEditable value from cell and render with different color?

Please help me .
Re: How to change the cell background color? [message #1517408 is a reply to message #1516798] Fri, 19 December 2014 13:28 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
That depends on how you use the editable approach. Do you implement a custom rule? In that case you need to find a way to access the ConfigRegistry or the ILayerCell in your accumulator. Or if you register rules based on labels, use the same labels.
Re: How to change the cell background color? [message #1517559 is a reply to message #1517408] Fri, 19 December 2014 15:39 Go to previous messageGo to next message
Srinivas Umareddy is currently offline Srinivas UmareddyFriend
Messages: 4
Registered: December 2014
Junior Member
Hi Dirk,

I have used some custom rule and also IEditableRule.NEVER_EDITABLE. We override the getConfigLabelsByPosition() method in the DataLayer like below. Its working fine.
In my table editable/non editable is dynamic not the static and its controlled from other UI field in the same application. During the loading of the table, the entire table might be editable when the users change some option in the table or outside the table then we have to disable some columns cells in the row and paint cell with gray color.

In order to implements this requirement, I have override the datalayer like below. I found this is calling very time and repairing the cell. I was able to get the isEditable flag from the configuration.
Please let me know is this right approach.


bodyDataLayer = new DataLayer(bodyDataProvider)
{
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition,
int rowPosition) {
// TODO Auto-generated method stub
LabelStack configLabel = super.getConfigLabelsByPosition(columnPosition, rowPosition);

ILayerCell layer = super.getCellByPosition(columnPosition, rowPosition);

IEditableRule editableRule = (IEditableRule)configRegistry.getConfigAttribute(
EditConfigAttributes.CELL_EDITABLE_RULE,
"EDIT", configLabel.getLabels());

boolean isEditable = editableRule.isEditable(layer, configRegistry);
if(isEditable)
{
getConfigLabelAccumulator().accumulateConfigLabels(configLabel, columnPosition, rowPosition);
configLabel.addLabelOnTop(MyUICommon.EDITABLE_LABEL);
}
else
{
getConfigLabelAccumulator().accumulateConfigLabels(configLabel, columnPosition, rowPosition);
configLabel.addLabelOnTop(MyUICommon.NONEDITABLE_LABEL);
}
return configLabel;
}
};
Re: How to change the cell background color? [message #1517661 is a reply to message #1517559] Fri, 19 December 2014 17:05 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Overriding the method is typically not the correct approach since we have accumulators. But if it is working for you, keep it.
Previous Topic:Filter for ComboBoxCellEditor editor
Next Topic:Radio Buttons in Nattable
Goto Forum:
  


Current Time: Thu Apr 25 13:08:31 GMT 2024

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

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

Back to the top