I have a column that is basically an object, I display the value I want to display, but the sort does not work for that column.
Attach an example so I can explain myself a little better.
for example:
const [data, setData] = useState([
{
ID: "A001",
Name: "Joe James",
Amount: "$300,000",
Purpose: "$220,000",
Tib: 12 + "years",
details: {Score: "620-670" , Name:"Joe James"},
Score: "620-670",
Phone: "9292132019",
Mail: "[email protected]",
State: "TX",
Opening: "11.11.2021",
Pf: "Priority urgent",
Flags: "In Progress",
Ls: "DorAff",
Company: "Dit",
Ras: "...",
},
{
ID: "A001",
Name: "Joe James",
Amount: "$300,000",
Purpose: "$220,000",
Tib: 12 + "years",
details: {Score: "650-720" , Name:"Test James"},
Score: "620-670",
Phone: "9292132019",
Mail: "[email protected]",
State: "TX",
Opening: "11.11.2021",
Pf: "Priority urgent",
Flags: "In Progress",
Ls: "DavAff",
Company: "Mit",
Ras: "...",
}
)];
const columns = [
{
name: "details",
label: "Name",
options: {
customBodyRender: (value: any, tableMeta: any, updateValue: any) => {
return value?.Name;
},
sort: true,
filter: true,
setCellProps: () => ({
align: "center",
}),
setCellHeaderProps: (value: any) => ({
className: "centeredHeaderCell",
}),
},
},
{
name: "details",
label: "Score",
options: {
filter: true,
sort: true,
customBodyRender: (value: any, tableMeta: any, updateValue: any) => {
return value?.Score;
},
setCellProps: () => ({
align: "center",
}),
setCellHeaderProps: (value: any) => ({
className: "centeredHeaderCell",
}),
},
}
]
As you can see in the example I go to the details and display the Name, and in another column displays the Score.
Thanks in advance :-)