columns.render does not work

columns.render does not work

lucaslmlucaslm Posts: 5Questions: 1Answers: 0

Hello,

I am using Datatables with server side precessing. My goal is to have a column which uses several properties of my data source to assemble each cell html. At first I though of setting the option columns.render to a function, and columns.data to null, in accordance to their specifications.
However, regardless of the value I pass to columns.data, it doesn't seem to work, and I get that warning saying that the parameter is unknown. Odd enough, if I set columns.defaultContent, the warning goes away, but I get stuck with a fixed value for all the column's cells.
I was able to reproduce this issue in a plunkr

https://plnkr.co/edit/XJeuxNe8rlLFQwyHXJYu?p=preview

Could it be that the documentation is outdated and I am passing an invalid combination of options?
It would be great to find out what the problem is.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946
    Answer ✓

    Made a few changes here:
    https://plnkr.co/edit/UiCoiub22t9CepXwTJ4X

    Changed from using columnDefs to columns simply because you are configuring each column individually and columns takes precedence over columnDefs. Also note I removed the targets option as that is not used with columns. However you can stick with your columnDefs and it will still work with the following two changes.

    In your last column I made the following changes:

    • Commented out "data": null, and added defaultContent: '',
    • Moved the return string to start on the same line as the return statement. Apparently Javascript does not recognize the string if it starts on the next line.

    Kevin

This discussion has been closed.