gregnb / gregnb/mui-datatables
Column CustomHeadRender reuse the sortToggle function
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 906
- PR merge metrics
- No merged PRs in 30d
Description
## Column CustomHeadRender rehuse the sort function
Right now I want to create a custom head and use the sort function provided by the table.
## Current Behavior
right now is not possible,
### Proposal
I noticed the sort function is passed on the **customHeadRender** function so I made a few changes on the MUIDataTableHead component
line 55
``` javascript
column.customHeadRender({ index, ...column }, (columnIndex) => this.handleToggleColumn(columnIndex))
```
This give us the oportunity of continue using the sortToggle using the current index or other column index. :) I changed the name to _columnIndex_ because the name index is shared inside of the map function on columns array.
```javascript
const columns = ["Name", "Title", "Location", "Age", {
name: "Salary",
sortDirection: 'asc',
options: {
customHeadRender: ({index, ...column}, sortColumn) => {
return (
sortColumn(index)} key={index}>
{column.name}
);
}
}
}];
```
I can create the PR to include this small functionality.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.