Question

I have created a CellTable with 300+ rows divided into pages of 20. I have a command in my menu that allows the user to highlight rows based on values in some column (similar to conditional formatting in Excel).

What I need help with is changing the row styles for rows that are not on the current page.

I've looked through the Celltable and SimplePager documentation but nothing has jumped out at me. I'm very new to GWT so any help would be much appreciated.

Was it helpful?

Solution

I created a function that looked like this (where redRow and yellowRow are styles in my CSS):

private void highlightAlerts() {
    alertHighlight = true;
    Range range = siteTable.getVisibleRange();
    int start = range.getStart();
    for (int i=0; i<siteTable.getPageSize(); i++) {
        if (dataProvider.getList().get(start+i).alert.equals("Error"))
            siteTable.getRowElement(i).setClassName("redRow");
        else if (dataProvider.getList().get(start+i).alert.equals("Warning"))
            siteTable.getRowElement(i).setClassName("yellowRow");
    }

Then in my pager I added this to onRowOrRowCountChanged() so that the styles would persist as the user went through the pages of the table:

protected void onRangeOrRowCountChanged() {
    super.onRowOrRountCountChanged();
    if (alertHighlight)
        highlightAlerts();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top