1

I have add button in each row ,but I want to check if info column data is N/A, then not shown the button, I have try to set render as below in my code ,but it's not work

{
    "targets": -1,
    "data": null,
    "render": function ( data, type, row ) 
    {
        if (row.info != 'N/A') {
        return "<button href='" + row.index() + "' class='btn btn-info'>View</button>"
        } else { return "" }
     }
    }                    
}

Any help/advice is greatly appreciated. Willing to post any more information if it will help.

1
  • "render": function ( data, type, row ) { if (row.info!='N/A') return "<button href='"+row.index()+"' class='btn btn-info'>View</button>" } Commented Nov 10, 2016 at 15:11

2 Answers 2

3

Render is documented here: https://datatables.net/reference/option/columns.render

You aren't using the same name of arguments documented there, but in the examples, you would use full to access all of the available columns and data is the current column. I'm not sure where you got field from. So data from info would be accessed at full.info.

An example being:

"render": function ( data, type, full, meta ) {
  return '<a href="'+data+'">' + full.info + '</a>';
}
Sign up to request clarification or add additional context in comments.

Comments

1

Working Link Here

"render": function(data, type, full, meta ) {
    if (full.info != 'N/A') {
        return "<button href='" + row.index() + "' class='btn btn-info'>View</button>"
    } else {
        return ""
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.