Group index

Group index

srgloureirosrgloureiro Posts: 7Questions: 2Answers: 0
edited March 2023 in Free community support

Is there a way to get the group index on the startRender event? I need in each row to get on what group number I am currently.

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    See the rowGroup.startRender docs for all the parameters passed into the function. Sounds like you are wanting the group parameter.

    Kevin

  • srgloureirosrgloureiro Posts: 7Questions: 2Answers: 0
    edited March 2023

    @kthorngren This is not what I want.
    What I want is an index of the group, not its title.
    I ended up implementing a solution each time the startRender runs, incrementing an iterator counter, based on that group title text, comparing it to the previous one.
    Not an approach I like very much, but it works.

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    edited March 2023

    I don't believe rowGroup.startRender has an index. Its not really something Datatables tracks as part of the table data. It just inserts tr elements into the HTML table for display. Maybe you can describe what you are trying to do to see if there is another option.

    EDIT: Note that the rowGroup.startRender only groups the rows that are displayed on the page not all rows in the table. So the groups processed on one page might different on the next page.

    Kevin

  • srgloureirosrgloureiro Posts: 7Questions: 2Answers: 0
    edited March 2023

    In my case, I don't have pagination, and even if I had, I would only need it for current page.
    Thanks any way.

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin

    If we were to take this example, do you mean you would want the startRender for "Edinburgh" to be passed in 0, for "London" 1, "New York" 2, etc? Or something else?

    Allan

  • srgloureirosrgloureiro Posts: 7Questions: 2Answers: 0

    @allan Yes. And in my case I needed it for sub-groups, so I did reset the counter every timed I entered a new group.

Sign In or Register to comment.