Column formatting for server-side data
Column formatting for server-side data
bikedorkseattle
Posts: 20Questions: 1Answers: 0
Hello,
I've just started getting my feet with DataTables and have actually had quite a bit of luck getting server-side data working with column filtering.
Where I'm struck right now is I'm failing to find any instructions on how to do column formatting outside of the built in type detection. For instance, I'm passing back a thread ID (for a forum) in my json data and I'd like to build the URL client side since it's the same string minus the thread ID for every link, and I can't modify my DB. Can I do this client side in datatables or am I better modifying my server response to include the link.
Another example of the same problem I'd like to send back a link and have a "Buy Now" image and link in the cell. How do you go about doing this? I've spent hours going through documentation and the forums and failing to find information.
TIA
I've just started getting my feet with DataTables and have actually had quite a bit of luck getting server-side data working with column filtering.
Where I'm struck right now is I'm failing to find any instructions on how to do column formatting outside of the built in type detection. For instance, I'm passing back a thread ID (for a forum) in my json data and I'd like to build the URL client side since it's the same string minus the thread ID for every link, and I can't modify my DB. Can I do this client side in datatables or am I better modifying my server response to include the link.
Another example of the same problem I'd like to send back a link and have a "Buy Now" image and link in the cell. How do you go about doing this? I've spent hours going through documentation and the forums and failing to find information.
TIA
This discussion has been closed.
Replies
http://www.datatables.net/forums/discussion/2275/how-to-display-an-image-column-when-using-json-data/p1
http://www.datatables.net/forums/discussion/1959/image-thumbs-in-table-column.-lazy-loading/p1
http://www.datatables.net/ref#fnRowCallback
[code]
"aoColumnDefs": [
{
"aTargets": [ 1 ],
"fnRender": function ( o, val ) {
var link = "" + o.aData[1] + "";
return link;
}
},
{
"aTargets": [2],
"fnRender": function ( o, val ) {
var link = "";
return link;
}
}
]
[/code]