Question

I want to style a single row and avoid defining formatters for each cell of my row. Is there an equivalent of the onStyleRow event for the new Dojo dgrid widget?

Thanks.

Was it helpful?

Solution

I ended up with two distinct solutions:

  1. In the controller using the dgrid, based on the workaround given at https://github.com/SitePen/dgrid/issues/236#issuecomment-11508012

        aspect.after(myDgrid, "renderRow", function(row, args) {
            var data = args[0];
            if (data.unread) {
                domClass.add(row, "unread");
            }
            return row;
        });
    
  2. In my own dgrid definition, but without "use strict" - otherwise this won't work and you'll get this error: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them:

    return declare("com.my.myDgrid", [ Grid, ... ], {
        columns : [ {
            ...
        } ],
    
        renderRow : function() {
            var row = this.inherited(arguments);
            var data = arguments[0];
            if (data.unread) {
                domClass.add(row, "unread");
            }
            return row;
        }
    });
    

The styling is done via this simple CSS rule:

    #myDgridId .unread td {
        font-weight: bold;
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top