cells() selector : strange

cells() selector : strange

trucmuche2005trucmuche2005 Posts: 71Questions: 22Answers: 2

Hello,

I have a small question about cells() selector. I wrote this :

$('#table').on('draw.dt', function ( e, settings, json, xhr ) {
      var api = new $.fn.dataTable.Api( settings );
        api.cells( null, 'statut:name',  {page:'current'} ).nodes().each( function(){
            console.log("hello");
        } );
    } );

and I display my table which shows only the 25 first rows (of the 2800 rows loaded in the table).
I was expecting to see in the console 25 times the word "hello". But I see 25 + 150 times this word. Why ??
I can't understand this... Could you explain that to me ?

Many thanks in advance,

T.

Answers

  • kthorngrenkthorngren Posts: 21,354Questions: 26Answers: 4,956

    When you first initialize the table you should see this 25 times. But it will display on any draw event. Are you doing anything that would cause the table to redraw 150 times?

    Probably will need to see your JS code to understand why you are seeing the 150 extra times "hello" is output.

    Kevin

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    It would need to be redrawing 6 times to show the console message 150 times. But that still seems like a lot of draws that wouldn't be required.

    @trucmuche2005 - Can you link to a test case showing the issue please?

    Allan

This discussion has been closed.