NeXTs / Clusterize.js

Tiny vanilla JS plugin to display large data sets easily
https://clusterize.js.org
MIT License
7.22k stars 412 forks source link

Can you create a callback when Clusterize finished to work ? #115

Open khalyomede opened 7 years ago

khalyomede commented 7 years ago

Hi there,

Could we imagine I could use Clusterize.js to wait when it finishes to work to do some other javascript ? In fact I would like to apply DataTable.js to filter my values, but when I use it DataTable says to me that the table does not have any rows, and in fact it is because Clusterize.js was still working on it. I imagine somethings like :

var data = [];

for( var i = 0; i < 9000; i++ ) {
    data.push('<tr><td>Hello World!</td></tr>');
}

var clusterize = new Clusterize({
    rows: data,
    scrollId : 'scrollArea',
    contentId: 'contentArea',
    callbacks: {
        clusterReady: function() {
            $('#scrollArea>table').DataTable(); // Here would be great !!
        }
    }
});

If you can do this this library would be one of my best friend ! I reommand it already around me, nice job guys !

NeXTs commented 7 years ago

Hey how about

callbacks: {
  clusterChanged: function() {
    setTimeout(function() {
        $('#scrollArea>table').DataTable();
    }, 0)
  }
}
khalyomede commented 7 years ago

I tryied on JSFiddle, this work for a small amount of data : https://jsfiddle.net/cLp25uww/2/, but with a large amount of data : https://jsfiddle.net/cLp25uww/1/ DataTable throw an error cannot set property of undefined.