gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 932 forks source link

Default value when cell is empty? #1256

Open masaok opened 4 years ago

masaok commented 4 years ago

Expected Behavior

Is there a way to set a "default value" when a cell is empty?

The feature would be similar to this jQuery datatables: https://datatables.net/reference/option/columns.defaultContent

Current Behavior

Empty cells are currently empty by default, but the table looks broken to some users, so a default dash value would be more meaningful.

Steps to Reproduce (for bugs)

N/A

Your Environment

Tech Version
Material-UI 4.9.10
MUI-datatables 2.14.0
React 16.13.1
browser Chrome

Example of empty cells:

image

hasanbisha commented 4 years ago

i guess you could add this option to the column customBodyRender: value => {value ? value : "Whateve you would want to put here"} i know it is kinda like a work around but i don't think the datatable has the option for default values i hope it helps

haase1020 commented 3 years ago

Has anyone had any luck with implementing this? I am trying to push the null values to the end of the table for each column, but the following is not working

customBodyRender: (value) => {
      return value === null ? "-" : value
    },