NeXTs / Clusterize.js

Tiny vanilla JS plugin to display large data sets easily

Home Page:https://clusterize.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.filter() function and draw callback to save memory

JYone3A opened this issue · comments

We want to show a list of lots of records and want to be able to filter them. That is why we need to keep the original array of the records (with the raw data) besides the array of HTML strings we provide to clusterize. When filtering, we use the raw data to find out what records should be shown, select those entries from the HTML strings array and send it to clusterize .update()

So basically, we need to versions of our data.

If we had two additional functionalities in clusterize I think we could make that more efficient:

  • if we could define a draw callback that is executed for each row before appending it to the DOM, we could use this function to convert the raw data to the HTML string. Therefore we would not have to keep a separate array with the HTML strings besides the raw data, and could use the raw data array in clusterize.
  • instead of calling .update() with a filtered array, it would be awesome if there was an .filter() function in clusterize where we can pass an array of row numbers. Clusterize would then redraw with the data it is initialized with currently, but would only show the rows that are listed in the array send to .filter()

I could try to implement some code, but I wanted to make sure that there are no better ways to save memory, and maybe get some directions where to start.