PDA

View Full Version : Need help! Background-color in cell without padding!



geschel
10 Apr 2012, 12:41 AM
Hi

I am trying to set the background color of an individual cell (WITHOUT cellpadding) in a Grid.
So far the only successfull way was to set it manually with Firebug - and that is difficult to communicate to the customer :)
Is there a way in GXT to access the surrounding div of this cell in order to set its style?
How can i modify this generated css class "GDT2WDTHGC" ?

thank you in advance
geschel


33812

esag_dk
11 Apr 2012, 6:23 AM
Have you tried adjusting the width and height of the cell's content?
Anyway, I assume this is a better approach:

getView().setViewConfig(new GridViewConfig<MODEL>()
{

@Override
public String getRowStyle(MODEL model, int rowIndex)
{
return CSS_STYLE;
}

@Override
public String getColStyle(BankProductOrSegment model,
ValueProvider<? super BankProductOrSegment, ?> valueProvider, int rowIndex, int colIndex)
{
return CSS_STYLE;
}
});

This sets a custom style to a row/column depending on contained object and row/col index. This way you can set the desired background color for the entire cell and not only the contained text. But don't forget to return the css style name and not the style itself (so don't return "background-color: xx" but the corresponding style name defined in your css file). And "!important" may be needed to really color the cell (at least I needed it).

geschel
12 Apr 2012, 4:02 AM
works fine now with '!important', thanks a lot!