Dynamic row background colour
Hi Allen,
I want to assign row background color as dynamic such as colour code is retrieving from the database table. I want to also provide a different row highlight colour when it is selected with checkbox. So, when I de-select any row, it should retain the old colour (which I have set dynamically)
Can you please let me know how to achieve this?
Cheers, Romil
I want to assign row background color as dynamic such as colour code is retrieving from the database table
https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/style/tr-class-function-table.js#L24
I want to also provide a different row highlight colour when it is selected with checkbox.
we can only assign a string color code in selectRow.bgColor and I think I can support this to accept a function to have more flexibility.
Is there any update on this issue?
Kind Regards, Anika
@anikakalbrun, sorry I'm really busy in this couples weeks, I'll do it ASAP.
Hey @AllenFang , thanks for the update. I am looking forward for that feature to be implemented.
Fixed on v3.1.4, please have a look and check this for example, thanks.
Thanks @AllenFang, this works perfectly for me. Great Job!
Tip: If you can't use class and need to use style (I got the tr color from my back end for example) there is also trStyle.
https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/style/tr-style-table.js
Have been trying for quite a while and this puzzles me quite a bit.
getTrProps={(state, rowInfo, column, instance) => {
return {
onClick: (e, handleOriginal) => {
console.log('A Td Element was clicked!')
console.log('it produced this event:', e)
console.log('It was in this column:', column)
console.log('It was in this row:', rowInfo.original.transactionStatus)
console.log('It was in this table instance:', instance)
// IMPORTANT! React-Table uses onClick internally to trigger
// events like expanding SubComponents and pivots.
// By default a custom 'onClick' handler will override this functionality.
// If you want to fire the original onClick handler, call the
// 'handleOriginal' function.
if (handleOriginal) {
handleOriginal()
}
},
style: {
background: ((rowInfo.original.transactionStatus == "settled") ? "tableHighlight": "" )
}
}
}}
When I console log "'It was in this row:', rowInfo.original.transactionStatus", it works.
However once I add the styles, calling the same "rowInfo.original.transactionStatus". It gives me the error of "Uncaught TypeError: Cannot read property 'original' of undefined".
This should be easy but I can't seem to see where the error lies.