Grid: How to get a column index


I have a grid on the page which allows user to be able to drag and drops columns the way it makes sense for him.

How can i get a column index by id?


Hello, You can make a function that passes the id, and traverses the columns of the grid, using the array’s findIndex() function.

I believe that the grid by itself does not have something specific for this. I hope it helps.

function getIndexById(idColumn) {
    return grid.config.columns.findIndex(function(element) { return === idColumn});


if the user has dragged some of the columns to another index this wont work because the columns indexing in the grid.config.columns are immutable.

Am i wrong?


It is not immutable, if you change the column position by dragging and checking the columns, the index will be updated. I made an example snippet for testing.