Using rowCallback to vary the Render Function
Using rowCallback to vary the Render Function

I am very new to Datatables and Developing and would be delighted for a few pointers please
I have a column in a table as below. It renders with +/- buttons to vary the quantity which all works fine (except the text alignment??).
data: "in_qty",
classname: "dtTextCenter",
render: function (data, type, row) {
if (type === "display") {
return (
data +
`<div>
<i class="fa fa-plus-circle inc changeVal"></i>
<i class="fa fa-minus-circle dec changeVal"></i>
</div>`
);
}
return data;
},
For some rows I don't want the +/- buttons displayed dependent on the value in another column
Is it possible to hide the buttons using rowCallback
rowCallback: function (row, data, index) {
if (data.has_sn == "1") {
//Don't show +/- Buttons
}
}
Thanks in anticipation
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You could do that still in your first code block. The third parameter in your code
columns.render
isrow
, which is the data for the entire row - so you can do a test on that and return an empty string when you don't want the buttons.Colin
Thank you so much!