gregnb / gregnb/mui-datatables

Conditional formatting

Open
#1,043 3 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
2.7k
Forks
906
PR merge metrics
No merged PRs in 30d

Description

## Expected Behavior

I'd like to be able to format cells based on the value in it to produce, for example, colour gradients based on values. This is a popular feature [in Excel](https://support.office.com/en-gb/article/use-conditional-formatting-to-highlight-information-fed60dfa-1d3f-4e13-9ecb-f1951ff89d7f).

## Current Behavior

I've found a couple of ways to do this but none are quite satisfactory and I was wondering if there are any other suggestions.

The simple method is to use a `customBodyRender` and then insert a styled `` with a background colour. The problem with this approach is that it only colours the little box in the middle of the cell which looks a bit rubbish:

![image](https://user-images.githubusercontent.com/50494132/68077009-3bc1ad80-fdb4-11e9-8ef5-444a2d0c2e0f.png)

The other approach is to use `customRowRender`, which allows full control over everything so that I can restyle the table elements that own the values, but this means I have to reimplement all the row rendering from scratch including all the nice built-in logic I would usually get for selecting rows:

![image](https://user-images.githubusercontent.com/50494132/68076997-10d75980-fdb4-11e9-98ca-c8dc2a6bfe28.png)

I also wondered whether there was some CSS-based approach but I was unable to come up with one.

(as an aside, I used [Chroma](https://gka.github.io/chroma.js/) to do the colouring and it's really awesome)

## Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | 4.4.0 |
| MUI-datatables | 2.10.2 |
| React | 16.9.0 |
| browser | |
| etc | |

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue points to the customBodyRender and customRowRender entry points; start by reading their current table-rendering behavior and related documentation or tests. Done means a supported conditional-formatting path can style the cell area while preserving built-in row-selection behavior, though the exact API is not defined in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.