How to hide only some child rows which are empty
How to hide only some child rows which are empty
[Deleted User]
Posts: 0Questions: 6Answers: 0
Referencing to: https://datatables.net/examples/api/row_details.html
Let's say that I have a few rows without an extension number. Therefore I don't want to show the line "Extension number: [...]" only in the few ones which don't have one. I am not quite sure how to do that.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
in the example the
format
function builds the child row display. You can use if statements to see if there is a value for extension and only append the row to the string if there is.Kevin
How does that statement have to look like? My empty extn entries have the value "empty"
I tried that in the format function:
if(d.extn == "empty"){
// dont show anything
}
else{
'<td>Extension number:</td>'+
'<td>'+d.extn+'</td>'+
But this isnt working.
I would guess that it has to do with how you are appending the strings. Likely you are getting an error in your browse's console due to where you have the
+
placed.Maybe something like this:
EDIT: Made a couple changes.
I didn't try this so there may be errors. If you still have problems please build a simple test case showing what you are trying to do so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin