Skip to content

How do I create auto incrment number in the Grid field for all the rows that appear? #7222

Answered by ra-bedo11
ra-bedo11 asked this question in Help
Discussion options

You must be logged in to vote

protected getColumns() {
let columns = super.getColumns();

    // Add an auto-increment column
    columns.unshift({
        field: 'RowNumber',
        name: 'No',
        format: ctx => {
            let pageIndex = this.view.getPagingInfo().page - 1; // Adjusting for zero-based index
            let pageSize = this.view.getPagingInfo().rowsPerPage;
            return (pageIndex * pageSize) + ctx.row + 1;
        },
        width: 40,
        minWidth: 40,
        maxWidth: 40
    });

    return columns;
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ra-bedo11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant