Sorting table column #440
-
Hi,
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, // TableData
function getTableData() {
(async () => {
setSmartTableList(await SmartDeviceDecorator.getSmartDeviceData());
})();
}
//Column
const tableColumns = React.useMemo(
():Columns[] =>
[
{
Header: 'Table',
columns: [
{
Header: '',
accessor: 'image',
id: 'image',
Cell: (props) => {
return <img src={props.row.original.getIcon()} width={SmartDeviceMarker.iconSize + "px"} alt={props.row.original.alt}></img>
}
},
{
Header: 'Name',
accessor: 'smartDeviceId',
id: 'name',
fieldType: 'text',
},
{
Header: 'Status',
accessor: 'laststatus',
id: 'status',
fieldType: 'text',
Cell: (props) => {
const { backgroundColor, color } = props.row.original.getCellColors();
return <div className="iui-cell" key={props.row.original.laststatus } style={{ backgroundColor, color, padding: "10px", justifyContent: "center"}}>
{props.row.original.laststatus}
</div>
}
},
{
Header: 'Value',
accessor: 'lastvalue',
fieldType: 'text',
id: 'lastvalue',
}
]
}
], [],
); |
Beta Was this translation helpful? Give feedback.
Hey,
I see you are passing React elements as a data fields. What you should do instead is to use
Cell
property in column. Also, for sort to work you need to useaccessor
property in column to pass required field to the Table. Here is the fixed code: