mRender interfer with sorting of columns???

mRender interfer with sorting of columns???

comfunercomfuner Posts: 9Questions: 0Answers: 0
edited January 2014 in DataTables 1.9
I've applied mRender on columns to turns numbers into images (1 -> 1 star, 2 -> 2 stars, etc...)
now I can't sort the "changed" columns, why?

this is the code:

[code]

...
"aoColumnDefs": [
{
"mRender": function (data, type, row) {
img_str = '';
return img_str;
}, "aTargets": [9, 8, 7, 6, 5, 4, 3, 2]
},
{ "sClass": "center", "aTargets": [9, 8, 7, 6, 5, 4, 3, 2] }
],
...
[/code]

Replies

  • comfunercomfuner Posts: 9Questions: 0Answers: 0
    here is the project link:

    http://www.haaretz.co.il/st/inter/tests/Elijahu/critic/1/index1.html
  • netametanetameta Posts: 39Questions: 0Answers: 0
    edited January 2014
    You need to check you cant simply turn them into images Try this:


    [code]
    "aoColumnDefs": [
    {
    "mRender": function (data, type, row) {
    // checking if type is display - otherwise you change things you dont need
    if(type == 'display'){
    data = '';
    }
    return data;
    }, "aTargets": [9, 8, 7, 6, 5, 4, 3, 2]
    },
    { "sClass": "center", "aTargets": [9, 8, 7, 6, 5, 4, 3, 2] }
    ],
    [/code]

    Let me know if that helped.
  • allanallan Posts: 63,493Questions: 1Answers: 10,470 Site admin
    Exactly as netameta says!! In DataTables terminology this is "orthogonal data".

    Allan
This discussion has been closed.