Column formatting for server-side data

Column formatting for server-side data

bikedorkseattlebikedorkseattle Posts: 20Questions: 1Answers: 0
edited June 2012 in General
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

Replies

  • bikedorkseattlebikedorkseattle Posts: 20Questions: 1Answers: 0
    Ok I've finally found some helpful threads, but if anyone else has some feedback it would be greatly appreciated. To reiterate, I'm doing this on servers-side data, I was able to do what I wanted with standard table data fine.

    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
  • bikedorkseattlebikedorkseattle Posts: 20Questions: 1Answers: 0
    edited June 2012
    Here is how I did it.

    [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]
This discussion has been closed.