mRender: return data variable as text (with html tags)

mRender: return data variable as text (with html tags)

JTavaresJTavares Posts: 3Questions: 0Answers: 0
edited September 2013 in DataTables 1.9
Hi,

Does anyone know how can I return the data variable as text - containing html tags - with mRender?

[code]
"mRender": function (data, type, full) {

return data;
},

[/code]

Thanks,
Jose

Replies

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin
    [code]
    return ''+data+'';
    [/code]

    perhaps?

    Allan
  • JTavaresJTavares Posts: 3Questions: 0Answers: 0
    Not lucky with ''

    [code]
    return '' + data + '';
    [/code]

    working with but 2 problems:
    - terrible formatting
    - using editable, the 'xmp' tags seems to be included on the input when user edit the cell

    Another approach:

    [code]
    "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {

    for(i=0; i!=aData.length; i++) {

    if (i == 7) {
    var dataht = oTable.fnGetData(nRow, 7);
    $('td:eq(6)', nRow).closest('td').text(dataht);
    }
    }

    },
    [/code]

    Problem:
    .text(dataht) not retrieving html tags

    any ideas?

    Thanks
  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin
    I had to look that tag up - used in HTML 3.2 and removed in 4: http://www.w3.org/TR/REC-html32#xmp . Wow :-)

    My point was that its just a string that mRender returns - you can have it return any HTML you want.

    Allan
  • JTavaresJTavares Posts: 3Questions: 0Answers: 0
    edited September 2013
    UPDATED:
    Hi

    Solved so far:

    2 things:

    1) apply "fnRowCallback"

    [code]
    "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {

    for(i=0; i!=aData.length; i++) {

    if (i == 7) { // 0 is where loop start; so it's applied to 8th column - my first one isn't visible;
    var dataht = oTable.fnGetData(nRow, 7); //get the data from each nRow, 8th column
    $('td:eq(6)', nRow).closest('td').text(dataht); //'force' result as text
    }

    }

    },
    [/code]


    optional - 2) change line 166 jquery.jeditable.js (Version 1.6.2)

    [code]
    //self.revert = $(self).html();
    self.revert = $(self).text(); //when reverting HMTL tags, do it as Text
    [/code]


    Sorry if there are some mistakes but i only start web prog. 2 months ago; just sharing just in case. ☺

    Thanks
    Jose
This discussion has been closed.