gregnb / mui-datatables

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

Is there a way to add Customized Header Labels, like multiline headers? #1248

Open arunkmr25 opened 4 years ago

arunkmr25 commented 4 years ago

Is there a way to add Customized Header Labels, like multiline headers?

Expected Behavior

I want to add two show two column data in one column, thus for rendering data, I can use render body and show multiple column values. but how do I add two labels in one column header?

Current Behavior

I tried doing this: const name= "

""
"Name"
""
""
"Id"
""
" { name: "dateTime", label: name},

but sorting fails by Maximum call stack size exceeded Note: i was not able to put "div", ignore the "" above.

Steps to Reproduce (for bugs)

Your Environment

image

Tech Version
Material-UI
MUI-datatables
React
browser
etc
kartiknegandhi commented 4 years ago

@gabrielliwerant I need similar multi header support too.Is there any such feature available?if not, then could u please help me with it? Need a feature in which we can provide nested objects in column like columns={[{ Header: 'Name', columns: [{ Header: 'First Name', accessor: 'firstName' }, { Header: 'Last Name', id: 'lastName', accessor: d => d.lastName }] }]}

such that we can have first name and last name under Name column as shown in the image

Screen Shot 2020-04-13 at 11 29 13 AM
wdh2100 commented 4 years ago

Hello @kartiknegandhi

In my opinion, implementing multi header now requires a complicated process.

customHeadRender function   Function that returns a string or React component. Used as display for column header. function(columnMeta, handleToggleColumn) => string\  React Component

First you have to header render with customHeadRender

customBodyRender function   Function that returns a string or React component. Used as display data within all table cells of a given column. function(value, tableMeta, updateValue) => string\  React Component Example

Second you have to column render with customBodyRender

rohangampa commented 4 years ago

Hi @wdh2100 even i am facing similar issue . i was not able to achieve using customHeadRender and customBodyRender

any small example would be helpful .

Thanks in Advance

wdh2100 commented 4 years ago

@rohangampa

ref : #1441

arezki1990 commented 3 years ago

Hello , i am facing the same problem any solution because i can't use neither exapnd nor customHeadRender

ivo96 commented 3 years ago

@rohangampa

ref : #1441

Hi the issue you are referring to is for expanding the rows. The issue here is for multi line headers . Can someone provide an example for those of us who are still trying to figure it out? Or at least if you could tell us how to insert two table rows in the header?

Thank you

vjravibuddy commented 2 years ago

Capture

i want exactly above the image in functional component

notHuy commented 1 year ago

Hi @vjravibuddy , did you find the solution for your problem. I am in the same case, but don't know how to do it