1.8 version and fnGetNodes() and bDeferRender: true

1.8 version and fnGetNodes() and bDeferRender: true

_jthomas_jthomas Posts: 75Questions: 0Answers: 0
edited June 2011 in DataTables 1.8
Hi Allan,
You have already mentioned that with 1.8 and deferrender set to true , fnGetNodes() will only return a subset of rows. For e.g. I am loading 500 rows through an ajax source with pagination set to 25. fnGetNodes is returning only 25, when I call that from fnInitComplete.

What I am trying to do is to add a column( dynamically to each row to hide and show the details of a record as explained in the example mentioned in the URL
http://www.datatables.net/release-datatables/examples/api/row_details.html.

How can I go about adding that additional data in this particular case? Do we need to capture any other event and when we paginate and add the additional ? Please advise and thanks very much!!!

Regards
Joson

Replies

  • _jthomas_jthomas Posts: 75Questions: 0Answers: 0
    Here is the code that works only for the first page. Which event should I capture to do the same thing for the rest of the pages. Thanks

    [code]
    "fnInitComplete": function() {
    $('#customer tbody tr').each( function () {
    this.childNodes[0].className = "center";
    this.childNodes[0].innerHTML = '';
    } );
    }
    [/code]
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    I would suggest that rather than inserting a new TD element like that - a better way would be to use mDataProp in a manner similar to that shown here: http://datatables.net/blog/Drill-down_rows

    Allan
  • _jthomas_jthomas Posts: 75Questions: 0Answers: 0
    Allan,
    That worked like a gem. This is good when it is the same value for all rows. How can we do this for different values. For e.g, I have data in one column where I need to wrap it with a href link. I am doing the following which naturally does not work from the second page onwards. Thanks

    [code]
    "fnInitComplete": function() {
    var nTds = $('td', this);
    this.childNodes[1].innerHTML = '' + $(nTds[1]).text() + '';
    }
    [/code]
  • _jthomas_jthomas Posts: 75Questions: 0Answers: 0
    Allan,
    That worked like a gem. This is good when it is the same value for all rows. How can we do this for different values. For e.g, I have data in one column where I need to wrap it with a href link. I am doing the following which naturally does not work from the second page onwards. Thanks

    [code]
    "fnInitComplete": function() {
    var nTds = $('td', this);
    this.childNodes[1].innerHTML = '' + $(nTds[1]).text() + '';
    }
    [/code]
  • _jthomas_jthomas Posts: 75Questions: 0Answers: 0
    I guess I can use fnRender function for the same. I will try it tomorrow and keep you posted. Thanks!!!
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Yup - fnRender for when you want to built up the string dynamically :-)

    Allan
  • _jthomas_jthomas Posts: 75Questions: 0Answers: 0
    fnRender worked like a charm. Thanks very much
This discussion has been closed.