java - GWT- CellTable--Trouble with setting row highlighting -
so little confused how set css of individual row in datagrid (which understand can use celltable can use).
first have double click , single click handler correctly called in 'oncellpreview'(had remove selectionmodel work). can row number through event.getindex().
next fail in attempt set css selected row, code:
int row= event.getindex(); mydatatable.setrowstyles(new rowstyles<string[]>(){ @override public string getstylenames(string [] rowobject, int therow){ if (row== therow){ return "mydatagridselectedrow"; } else return "mydatagrid"; } });
however don't understand how supposed work (which perhaps why can't work)
- how getstylenames() called? steps on in debugger.
- where should setrowstyles method call located in code?
i suppose work must remove call
mydatatable.setstylename("mydatagrid");
- there pre-existing css class in datagridoverride.css(which different main css file "mydatagrid" located). class ".datagridselectedrowcell" , has background color set (uses !important) not work.
this method setrowstyles()
called when table rendered.
you can set style dynamically way:
mydatatable.getrowelement(i).getstyle()...
or
mydatatable.getrowelement(i).setclassname("mydatagridselectedrow");
you not need remove style name grid.
edit:
an alternative approach override standard datagrid css resource:
how style gwt 2.1 celltables headers?
i recommend approach if want make many changes default gwt datagrid styles.
Comments
Post a Comment