Im set custom CssResource for DataGrid.
First column in table is ordered column with specific style. So when row is selected i need set another specific style for the order column.
Something like that:
You can override .getCellStyleNames
method for your column:
Column<Object, String> numberColumn = new Column<Object, String>(new TextCell()) {
@Override
public String getCellStyleNames(Context context, Object object) {
if (selectionModel.isSelected(object)) {
return "boldStyle";
}
};
Try with AbstractHasData#addCellPreviewHandler() .
dataGrid.addCellPreviewHandler(new Handler<T>() {
@Override
public void onCellPreview(CellPreviewEvent<T> event) {
if ("click".equals(event.getNativeEvent().getType())) {
table.getRowElement(event.getIndex()).getCells().getItem(0).getStyle()
.setBackgroundColor("#444444");
}
}
});
Note: This code is for SingleSelectionModel
. If you need it for MultiSelectionModel
then do same thing for all selected rows.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.