HTML table as data source and "data": null column
HTML table as data source and "data": null column
sergeda
Posts: 42Questions: 16Answers: 0
I need to show different icons for some rows. I set it in php and set this column as "data": null to not process it by Editor. But now it doesn't show up my content. I've tried to use columns.render but in this function I also doesn't have access to data in column. How can I achieve what I need?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I'm afraid I will need a little more information - I don't really understand what you are looking for at the moment. If you want to show icons, then
columns.render
probably is the best way to do it. The third parameter passed into the function is the data object for the whole row, while the first parameter is controlled bycolumns.data
(if you set it to null, thennull
is passed in as the first parameter).It would be helpful if you should link tot he page that you are having issues with or show some code.
Allan
In php I have code to form a table like this:
So if user have permissions to edit row I show him icons, if not - I don't show.
In JS for this column I have
I want in this render function somehow get content of my action cell but there is no this cell in data and row objects.
Doesn't your PHP template already do this? I don't see why you would need to render anything using Javascript.
Allan
The problem is: it renders fine only if I remove "data": null for this column.
With this:
all action cells doesn't have an icon and have [object Object]
Can you link to the page so I can debug it please?
Allan
Sorry, it is on my local computer now.
I've managed to render icons with this:
But with this I have another problem:
When I edit row in editor it returns row without this icons again :(
How can I render row the same way on editor save?
Can you render the icons using
return '<img .../>';
rather than reading from HTML that might or might not exist at that point (thenTr
property is not always available there).Allan
I don't have needed data in javascript to decide if icon should be placed or not. And make request to server on each row is not a good solution
You have access to the full data for the row and you could also add additional information to it that isn't displayed int he table if that isn't enough.
Allan
Can you give a bit more information. Some sample code? Can't get what you propose to do
It is hard to do so without being able to see the page since I don't know what data you have available, but here is a trivial modification of the code above:
Allan