Maybe see how the library from https://www.ag-grid.com/ does it or just use their library. If you check how many open bugs most JS grid/table projects have, it's clear implementing a robust grid with many features is really hard. I've used ag-grid for projects before and can recommend it (works with all major UI frameworks).