Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color whole row based on store data #236

Closed
chapgu opened this issue Jul 22, 2012 · 4 comments
Closed

Color whole row based on store data #236

chapgu opened this issue Jul 22, 2012 · 4 comments

Comments

@chapgu
Copy link

chapgu commented Jul 22, 2012

Hi,

Is there a way of styling a whole row based on the data in the row. i.e. if column x has data y in row z, set the background of row z to red.

Thanks,
Guy

@mikerobi
Copy link

Currently I wrap the row render function. It would be nice if the column definition accepted a function to generate the class.

@chapgu
Copy link
Author

chapgu commented Jul 23, 2012

Do you have any sample code you could share?

Thanks!

@vvanderm
Copy link

Looking to do something like this as well. Whats the best way to append some styling to the default rowRender functionality?

@ghost
Copy link

ghost commented Dec 18, 2012

This is possible, more or less efficiently depending on whether you're using Dojo 1.7 or 1.8.

In Dojo 1.7, you'd have to use aspect.around, in order to get at both the incoming object and the resulting row node:

aspect.around(grid, "renderRow", function(original) {
    return function(object) {
        var row = original.apply(this, arguments);
        // Apply classes to `row` based on `object` here
        return row;
    };
});

In Dojo 1.8, you have the option of using aspect.after - when its receiveArguments argument (4th arg) is left false, it actually passes not only the return value, but also the original arguments object as a second parameter. So you can do this in 1.8 much more easily:

aspect.after(grid, "renderRow", function(row, args) {
    // Apply classes to `row` based on `args[0]` here
    return row;
});

As for @mikerobi's idea of allowing specification of a function for column.className, I see two issues here:

  1. This would be at the cell level, not the row level
  2. The code in dgrid/Grid is unfortunately not laid out in a way to make this easily doable at the moment

I do think it's a useful idea, but it'd require more thought. Since I believe my response above addresses the question this issue asks, I'm closing it out.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants