Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is also another way of setting custom css formatting for selected row in DataGrid. You need to create your custom interface that extends DataGrid.Resources. In this interface you should ovveride method dataGridStyle() and in @Source annotaion put path to your custom css file. For example:</p> <pre><code>import com.google.gwt.user.cellview.client.DataGrid; import com.google.gwt.user.cellview.client.DataGrid.Resources; public interface CustomDataGridResources extends Resources { public interface CustomDataGridResources extends Resources { @Source({DataGrid.Style.DEFAULT_CSS, "resources/CustomDataGridStyles.css"}) CustomStyle dataGridStyle(); interface CustomStyle extends DataGrid.Style { } } </code></pre> <p>If you want just to change style for selected row then your css file will contain only:</p> <pre><code>.dataGridSelectedRow { background: #1EDA17; color: white; height: auto; overflow: auto; } </code></pre> <p>But I also prefer to change cursor for howered row:</p> <pre><code>.dataGridHoveredRow { cursor: pointer; cursor: hand; } </code></pre> <p>Look also at <a href="https://stackoverflow.com/questions/10877280/how-to-override-gwt-obfuscated-style-for-datagrid-header">similar discussion</a>.</p> <p>For applying custom style to your DataGrid you can use grid's constructor </p> <pre><code>public DataGrid(int pageSize, Resources resources, ProvidesKey&lt;T&gt; keyProvider) </code></pre> <p>where Resource is an instance that implements your custom interface (in my case <em>CustomDataGridResources</em>).</p> <pre><code>DataGrid.Resources customDataGridResources = GWT.create(CustomDataGridResources.class) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload