I'm using Tabulator 5.1 and it's been great so far. However I have a question that I hope is a quick answer.
I'm loading my data via AJAX, but I have a link column that I need help with. The link formatter works great and I set the "label" property so I can have them all uniform. However, I found that some of my rows coming into the table don't have a URL and when you use the label property it creates it for every row regardless of if there is a URL for it to make a link or not.
So my issue is that I have a column with links and some will send the user to the URL and others are "undefined" (null value from the AJAX call) and so they present an error page.
My question (finally) is, is there a way to blank out the rows that have a Null value while still being able to use the "label" property?
If I remove the "label" property the rows that don't have a URL blank out as expected, it's only when I try to use a label do I run into this issue.
EDIT: So I looked around some more and found a couple of things on the formatter. I see you can use a function to get the label however I can't see to get the logic working right. Here's what I've got so far that I'm trying to play around with:
label: function(cell){
if (cell.getData().title == "null"){
return ""
} else {
return "Click Here"
}
},
However that still only seems to get "Click Here" for every row.
Looks like I found outdated information. This is the code I used to get a custom label while still being able to leave the rows with blank URLs as a blank cell:
formatterParams: {
label: function(cell){
if(cell.getValue() == null){
return ""
} else {
return "Click Here"
}
},
target: "_blank"
},
That's my entire formatterParams value in case anyone needs it. I swore I had tried getValue() before, but this time it worked. Hopefully this helps someone in the future if they need this same thing.