2016-03-19 44 views
0

我正在嘗試更新鼠標懸停的行樣式。以編程方式更新GWT CellTable行樣式

mappings.addCellPreviewHandler(new Handler<MappingInstructionVO>() { 

     @Override 
     public void onCellPreview(CellPreviewEvent<MappingInstructionVO> event) { 
     if (BrowserEvents.MOUSEOVER.equals(event.getNativeEvent().getType())) { 
      mappings.getRowElement(event.getValue().getExecutionOrder()).getStyle().setBorderColor("Red"); 
     } 
}); 

我能夠得到禾一行內容成功地利用:

mappings.getRowElement(event.getValue().getExecutionOrder() - 1).getInnerText()); 

任何想法,爲什麼

mappings.getRowElement(event.getValue().getExecutionOrder()).getStyle().setBorderColor("Red"); 

有沒有影響?

感謝

回答

1

的DataGrid已在其默認DataGrid.Resources定義dataGridHoveredRow風格。一種選擇是在您自己的ClientBundle中重寫此樣式。

否則,請嘗試

.getStyle().setProperty("border", "1px solid red"); 

編輯:

您必須設置 「邊界崩潰:崩潰」 你的DataGrid中。

從CSS2規範:

在[邊界崩潰:單獨的模型]中,每個小區具有單獨 邊界。 [...]行,列,行組和列組不能有 邊界(即用戶代理必須忽略這些 元素的邊界屬性)。

+0

否您的建議無效。感謝您的回覆。 我也試過.getStyle()。setBorderStyle(BorderStyle.SOLID); 除了我有,但它沒有奏效。 – EMM

+0

如果可以的話,你還可以提供鏈接嗎?其實我想看看所有的屬性(不)支持。如果邊框不受支持,我想添加box-shadow。 – EMM

+0

「CSS2規範」,Google上的首個結果。對於表格邊界:https://www.w3.org/TR/CSS2/tables.html #borders –