ScoPi
ScoPi

Reputation: 1195

How do you create a table cell renderer that conditionally applies a text-decoration of line-through?

I'm trying to style a qx.ui.table.Table so some of its rows are conditionally styled with a text-decoration of line-through. I'm able to use qx.ui.table.cellrenderer.String to apply some styling, but not text-decoration changes. How can this be done?

Upvotes: 1

Views: 48

Answers (2)

Derrell Lipman
Derrell Lipman

Reputation: 616

You are talking about trying to modify the style of a cell when you refer to qx.ui.table.cellrenderer.String, but you stated that you wanted to style the whole row as line-through. If you really want to do it on a cell-by-cell basis, the style of a cell is determined in the cell renderer, by the _getCellStyle method. An example of its use is in the cell renderer qx.ui.table.cellrenderer.Conditional. Your case may be much simpler. In fact, if the conditions under which you ascertain whether to do line-through are available in the cell- or row data, you could extend qx.ui.table.cellrenderer.String, adding a _getCellStyle method that returns the desired style.

Likely, though, based on your description, you want to instead implement your own row renderer. You would create a row renderer that extends qx.ui.table.rowrenderer.Default, and override the createRowStyle method.

Upvotes: 2

goldim
goldim

Reputation: 460

There are odd and even rows and in default themes they have different background colors. You can set some state for rows which you want to. And after you can apply CSS styles to these states in style method of appearance.

"virtual-background-span": {
      alias: "widget",

      style(states) {
        var style = {
          decorator: "virtual-background-span"
        };

        if (states.odd) {
          style.backgroundColor = "table-row-background-odd";
        } else {
          style.backgroundColor = "table-row-background-even";
        }

        return style;
      }
    }

To add state use the method addState of Widget class.

Upvotes: 0

Related Questions