You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't seem to pass a valid JS function from the fnCreatedCell field of my getColumns() function in PHP
I can pass the JS function, which is encapsulated in a string, however that fails in the client-side with the error: Uncaught TypeError: n.fnCreatedCell.call is not a function because it isn't a function, its a string.
I don't know how else to pass this function without getting a PHP syntax error from trying to render the JS as PHP...
I have done the same thing when defining the createdRow parameter, using a string-encapsulation of the JS function, and that works as expected. Just not in this case, with fnCreatedCell
I can see from comparing sources I've found online to my own rendered+prettified JS source code, that I need the function to be de-stringified in order for it to work properly.
It seems like this is not yet supported by the builder. Will try to implement this when I got the chance. Please do not hesitate to submit a PR if you can. Thanks!
I was able to find a workaround, going off of #364.
Instead of addColumn, I used editColumn, and instead of performing cell functions via client side JS, I am instead using PHP to achieve the same effect, as per the linked issue.
Essentially, I am inserting a link into certain column(s), and then making sure it renders as HTML using rawColumns.
NOTE: This does affect column sorting according to the html (link) I am adding to the cells, which can very easily be a negative drawback, if adding the links makes the column sort in a different way. Luckily for me, in this specific instance, that is not the case.
I'd still like to be able to do it the right way, and not have to worry about HTML in cells breaking the sorting feature. But like I said, I have solved my immediate problem.
I can't seem to pass a valid JS function from the
fnCreatedCell
field of mygetColumns()
function in PHPI can pass the JS function, which is encapsulated in a string, however that fails in the client-side with the error:
Uncaught TypeError: n.fnCreatedCell.call is not a function
because it isn't a function, its a string.I don't know how else to pass this function without getting a PHP syntax error from trying to render the JS as PHP...
I have done the same thing when defining the
createdRow
parameter, using a string-encapsulation of the JS function, and that works as expected. Just not in this case, withfnCreatedCell
Snippets
OrderDataTable.php
Here is where I'm doing pretty much the same thing on the
createdRow
parameter, which is successfulJS Comparison
I can see from comparing sources I've found online to my own rendered+prettified JS source code, that I need the function to be de-stringified in order for it to work properly.
JS given to the client in my app:
JS I've found online from working examples:
So now hopefully you can see my problem. I need the value of
fnCreatedCell
to be an actual JS function, and not a string.System details
The text was updated successfully, but these errors were encountered: