Auto numbering based on filters

I have a list of rankings in a table

similar to this

1-Team A-SS-10.19

2-Team B-SDS-8.71

3-Team C- SDS-5.64

4- Team D- SS-5.11

5-Team E-SS-4.87

 

When I use my Filter Menu and filter for all SS teams What I want is...This:

1-Team A-SS-10.19

2- Team D- SS-5.11

3-Team E-SS-4.87

 

What I am getting is this:

1-Team A-SS-10.19

4- Team D- SS-5.11

5-Team E-SS-4.87

 

How would I get it to renumber the rows based on a filter? Anyone have an idea on this?

Hi Ryan, 

Here is the code to add this to your project. Make sure you add the correct view key:

Knack = Knack || {};
Knack.fn = Knack.fn || {};
Knack.fn.addCounters = function(key){
    let counter = 1;
    Knack.$(`#${key} tbody tr`).each((index, record)=>{
        //THIS WILL SELECT THE FIRST TD IN THE TABLE
        const currentTxt = Knack.$(record).find('td:first-child').text();
        Knack.$(record).find('td:first-child').text(`${counter}-${currentTxt}`);
        counter++
    });
}

//CHANGE THE VIEW TO YOUR VIEW KEY
$(document).on('knack-view-render.view_XXX', function(event, view, data) {
    Knack.fn.addCounters(view.key)
});


I work nearly full time inside of Knack. Let me know if you have any more questions regarding custom scripts.

Kelson
kelson@ksensetech.com
https://www.ksensetech.com/knack/

What's that first number, an auto-increment of the record?