TableFilter icon indicating copy to clipboard operation
TableFilter copied to clipboard

Add row number column

Open punx120 opened this issue 4 years ago • 1 comments

Hi

Thanks for the great library, is there currently a way to display the row number automatically? especially after sorting?

Thank you.

punx120 avatar Jan 18 '22 23:01 punx120

Ended up doing something a bit ugly:

       tf.emitter.on(['initialized'], parseRows);
        tf.emitter.on(['column-sorted'], (tf, sc, desc) => parseRows(tf));
        tf.init();
        // var stylesheet = tf.getStylesheet('default');
        // stylesheet.href = tf.themesPath + 'transparent/transparent.css'
        function parseRows(tf) {
            var cellIndex = 0; // POP column
            var rowsIdx = tf.getValidRows();
            rowsIdx.forEach(function(idx){
                var row = tf.dom().rows[idx];
                var cell = row.cells[cellIndex];
                cell.innerHTML = idx - 1
            });
        }

punx120 avatar Jan 19 '22 00:01 punx120

Well done, that's the idea: leverage the as much as possible the many hooks provided by the library 👍

koalyptus avatar Dec 28 '22 12:12 koalyptus