rows().columns().nodes().flatten().to$()

rows().columns().nodes().flatten().to$()

zapatazapata Posts: 13Questions: 5Answers: 1
edited April 2015 in Free community support

snc.a[s] contains title of TD. But I cant add each of title to each of 7th TD. BUT 7th TD always get value of last snc.a[s]

var newTable=$('#musteri_ara_table').DataTable({"bFilter" : false,"bLengthChange": false});$.ajax({
   type:"POST",
   url:"myUrl",
   data:"myData", 
   dataType:"json",
   success:function(snc){
        for(s=0;   s< snc.a.length;  s++){
           nod= newTable.row.add( [s+1,snc.a[s]]).draw();nod.rows(s).columns(6).nodes().flatten().to$().attr("title",s);}}

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    Can you link to a test page showing the issue, as per the forum rules, please.

    Thanks,
    Allan

  • zapatazapata Posts: 13Questions: 5Answers: 1

    http://www.resge.com/test/dTable.php

    As you will see, second column is red and its title is not that I want(Column Title has to be which artist's last name at each row). All second columns title is The last data Magic Johnson's last name.

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin
    Answer ✓

    You need to use an iterator - at the moment you have the code setting the title attribute for all of the cells in column 1, and the last one will "win".

    I would suggest using rows().every():

    newTable.rows().every( function () {
      $( this.cell( this.index(), 1 ).node() ).attr( this.data()[2] );
    } );
    

    You will need to updated to 1.10.6 to use rows().every().

    Allan

  • zapatazapata Posts: 13Questions: 5Answers: 1

    $( nod.cell(s,1).node() ) .attr("title",snc.lname[s]);
    that is ok. thanks!

This discussion has been closed.