AG-GRID Default Sort Model with Dynamic Column Defs

Alan Dragicevich picture Alan Dragicevich · Aug 12, 2017 · Viewed 11.1k times · Source

So I have a Grid setup that works with the Enterprise Row Model. The columns are very dynamic and so the column defs are not known until the first query for rows is made to the server. This all works fine, but how can I set a default sort state when the column defs are not set until after the request has succeeded?

Answer

Jonathan Naim picture Jonathan Naim · Aug 24, 2017

Once the grid has been set-up with the column defs you can just set the sort on any column

gridOptions.columnApi.getColumn(COLUMN_NAME).setSort("asc")