showing button on the if condition.
showing button on the if condition.
majkellvz
Posts: 8Questions: 3Answers: 0
I am on symfony 4 and I am trying to show a button depending on the status of a property if it is sold or not
{ "data": "issold",
"orderable":false,
render : function ( data, type, row ) {
if (data){
return '<a href="/property/sold/' + row.id + '" title="Sold"><i class="material-icons" style="font-size:25px">attach_money</i></a>';
} else {
return '<a href="/property/sold/' + row.id + '" title="UnSold"><i class="material-icons" style="font-size:25px">money_off</i></a>';
}
}}
EDIT: Updated to use Markdown formatting.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
You will need to fix your if statement. Something like this:
Kevin
it is a boolean type and still nothing
if (data === true){
@kthorngren I marked it answered by mistake
I don't see anything that stands out as an issue. We would need to see your data to help. Without actually seeing the problem we would just be guessing. Can you put together a simple test case?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
You could use a console log statement to see what the
data
is, for example:Kevin
@allan or @colin should be able to change it.
Kevin
console log is empty
Michael
I would suggest looking at the returned data using the browser's dev tools. Look at the network response. Is the
issold
object populated there?Kevin
Yea I found the error. Many thanks!