returning json, using mDataProp, and adding a span wrapping a value

returning json, using mDataProp, and adding a span wrapping a value

mgmg Posts: 47Questions: 0Answers: 0
edited August 2012 in DataTables 1.9
If I wanted to wrap the value in a table cell with a , giving some value,
then using DataTables 1.9.2, is there an example of the best way
to go about doing this when returning json in fnServerData and using mDataProp?

Replies

  • allanallan Posts: 63,683Questions: 1Answers: 10,498 Site admin
    edited September 2012
    There are a number of ways to do it:

    1. Get the server to return the data with the span tags always in place
    2. Use fnRender to add the span tags - *edit* Use mRender now - fnRender is deprecated.
    3. Use mDataProp as a function to add the span tags - http://datatables.net/blog/Orthogonal_data

    DataTables 1.9.3 will add yet another option - mRender - much like mDataProp but a little easier to use.

    Allan
  • rw1rw1 Posts: 42Questions: 0Answers: 0
    edited September 2012
    hello,

    solution i found using mRender to wrap the text with a div style eg cell text here:

    [code]
    "aoColumnDefs": [
    {
    "aTargets": [ 0 ],
    "mData": "0",
    "mRender": function ( data, type, full ) {
    return ''+data+'';
    }
    }
    ],
    [/code]
  • allanallan Posts: 63,683Questions: 1Answers: 10,498 Site admin
    Absolutely - mRender is now the way to do this :-). Thanks for posting.

    Allan
This discussion has been closed.