Displaying a field twice (or more) in a different manner

Displaying a field twice (or more) in a different manner

ericpanorelericpanorel Posts: 7Questions: 0Answers: 0
edited July 2012 in General
I have a list of objects, returned via json. The object (for simplicity sake) looks like:

[code]{ SalesOrder: 12345, Amount: 100}[/code]

Now I want to display it in such a way that the first column is a clickable button. So I used the fnRender trick:
[code]
{ "sName": "SalesOrderNumber",
"aTargets": [0],
"mDataProp": "SalesOrderNumber",
"bSearchable": false,
"bSortable": false,
"fnRender": function (oObj) {
var id = oObj.aData["SalesOrderNumber"];
var s = '';
s += '';
s += '';
return s;
} // fnRender
}, // SalesOrderNumber
[/code]

And the second column, will display the plain text value:
[code]
{ "sName": "SalesOrderNumber", "aTargets": [1], "mDataProp": "SalesOrderNumber" },
[/code]

However, this didn't work because the second column also displays in the same manner as the first column. Any ideas?
Thanks....

Replies

  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin
    Yeah - fnRender is a bit nasty - I'm trying to phase it out because of this exact behaviour! DataTables 1.9.3 is going to bring a nice new 'mRender' option which will make things easier, but until then, what you probably want to do is simply set bUseRendered : false on the columns where you are using fnRender. The disadvantage is that filtering and sorting will occur on the original string.

    For more advanced options, take a look at this post: http://datatables.net/blog/Orthogonal_data

    Allan
  • ericpanorelericpanorel Posts: 7Questions: 0Answers: 0
    Thanks Allan! The bUseRendered solution worked for me in this case, because I didn't need this fnRendered column to be sortable anyway.
This discussion has been closed.