2
votes

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.

1
Based on what I can understand, it seems the onStyleRow was abused. This post shows a possible solution if it meets your needs. - medokr
Yes, this comment: github.com/SitePen/dgrid/issues/236#issuecomment-11508012 but unfortunately this doesn't seem to work in Dojo 1.9 - maxxyme
OK got it, the code can't be added to the definition of my Dgrid, but in a context, like in a controller, where I actually create (with new keyword) my grid. - maxxyme
Nice job! Could you add your solution to your question for others with similar problem? - medokr

1 Answers

1
votes

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;
    }