Monday, March 24, 2014

Re: How to style specific cells in CellTable depending the value of that cell (GWT)?



On Monday, March 24, 2014 6:52:38 AM UTC+1, Tom wrote:
Hi Thomas, I tried, it almost done, BUT...

Suppose I want to style the cell that is the intersection of the following Row Index and Column Index: (Note: index start from 0, so column2 got index=1)

Row - Col
0      -  1
0      -  2
1      -  1
1      -  2
2      -  2

Clearly, I just want to style 5 cells only. 

So i did like you said:

in css file:

.boldRow .boldColumn { font-weight: bold; }

Then in the java file
column2.setCellStyleNames(getView().getRes().css().boldColumn());
column3.setCellStyleNames(getView().getRes().css().boldColumn());

table.setRowStyles(new RowStyles<List<String>>() {
   
@Override
   
public String getStyleNames(List<String> row, int rowIndex) {
 
 
     
if(rowIndex==0 || rowIndex==1 || rowIndex==2){
         
return getView().getRes().css().redRow();
     
}
     
return null;
   
}
         
});

ANd here is the result:

Col1 - Col2 - Col3  223 - 546 - 698  123 - 876 - 898  123 - 896 - 438

Clearly, i don't want this cell (row index =2 & columm index=3) bold. But the result include it.

So how to fix it?

Be creative! Use different row styles, and let's pick meaningful names for them: shouldColumn2BeBold, shouldColumn3BeBold, (applied to rows) and column2 and column3 (applied to columns; I think you could even use a single style name for the columns).

Rows 1 and 2 have shouldColumn2BeBold and shouldColumn3BeBold, row 3 has only shouldColumn3BeBold.

.shouldColumn2BeBold .column2,
.shouldColumn3BeBold .column3
 { font-weight: bold; }

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment