I have a react table (using react-table) component which looks as below. In the column State, I want to render button in each cell with dynamic values. These values I want to fetch from server data.
{
//Header: 'Download',
id: 'request_state',
filterable: false,
Cell: ({index}) =>
(<Button id={"approve_" + index}
value={<FormattedMessage id={"Approve_" + index} defaultMessage={"Approved"}
fontSize={14}
minHeight={33}
minWidth={"100%"}
backgroundColor="transparent"
borderRadius={5}
icon={<Download size={13} color={'black'}></Download>}
onClick={() => this.handleDownloadDelivery(index)}
/>)
}
Using above code, I could populate button in each cell with value "Approved". However, I want to populate this value dynamically using attribute values that I am getting in request_state attribute of the object "data" from server. Using "accessor:" I could access these attribute values of server side data, but I am not able to do the same for 'Cell:'. I could see string "invited" using accessor:
{
Header: 'State',
id: 'request_state',
filterable: false,
accessor: data =>{
let output =[];
output = data.request_state;
return output;
},
}
I basically want something like below:
{
//Header: 'Download',
id: 'request_state',
filterable: false,
Cell: ({index}) =>
(<Button id={"approve_" + index}
value={<FormattedMessage id={"Approve_" + index} defaultMessage={data.request_state}}
fontSize={14}
minHeight={33}
minWidth={"100%"}
backgroundColor="transparent"
borderRadius={5}
icon={<Download size={13} color={'black'}></Download>}
onClick={() => this.handleDownloadDelivery(index)}
/>)
}
