How to hide only some child rows which are empty
How to hide only some child rows which are empty
![[Deleted User]](https://secure.gravatar.com/avatar/896f3dbf19e4d835f8926273eae08919/?default=https%3A%2F%2Fvanillicon.com%2F896f3dbf19e4d835f8926273eae08919_200.png&rating=g&size=120)
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