Can Dear ImGui tables be sorted from somewhere else?

75 Views Asked by At

By default ImGui tables can be sorted by clicking on the column header. This sets internal table sorting state. Then, when supplying the contents of the table, user calls ImGui::TableGetSortSpecs() and retrieves the information about the current table sort state.

In addition to the above default behavior, I would like to have a button, located somewhere else, that would change - directly or indirectly - the sorting. Clicking on other columns' headers should retain the default ImGui sorting behavior. Is it possible?

  • I didn't find anything like that in Dear ImGui Demo Window.
  • I didn't find anything in the public API. Checked some of the internal source code too.

As a quick workaround I simply sort the data according to the new criteria, but table internal state is not aware of that change. The table still "thinks" it is sorted by old column. This causes:

  • Incorrectly showing up/down arrow at the wrong column
  • Requesting sorting again by wrong column if table decides that it needs to be sorted again for whatever reason. (by settings specs->SpecsDirty to true)
0

There are 0 best solutions below