質問

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.

役に立ちましたか?

解決

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;
    }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top