How do I get the column names of a table widget?

I would like to get an array with the column names. In the forum I could find this solution:
{{Table1.tableColumns.map((item)=> item.id)}}
But I get an error: tableColumns does not exist in Table1.

Is it a problem in the configuration of the table widget? Or has the table widget been changed in a recent appsmith release? In the documentation for the table widget, we can see (on the right) the sections General/ Events/Header options/Styles. But in the table widget I create, I see other sections: Data/Pagination/Search & Filters/Row Selection/Sorting/General. And it seems that tableColumns is not available anymore. Or do I just need to switch a configuration of the table widget to be able to use this property?

Hi Alf and welcome to our community! To get the column names of a Table widget, you can use:
{{Object.keys(Table1.tableData[0])}}
But note that this will return only the names of the properties of the first JSON Object of the array (aka the first row).
Let me know if this works.

Perfect, it works !
And what about the other formula:
{{Table1.tableColumns.map((item)=> item.id)}}
It still works with old Table Widget for compatibility reason?

Yes, that one still seems to work on older table widgets.

In the latest Table widget, you can use {{Table1.columnOrder}} to get the column names.

It works as well.
But I am not sure I quite catch the point: that means that there are different versions of table widgets and with some versions we can use some properties and with other versions the property cannot be used anymore?
Can we rely on the compatibility with older version so that the widgets are still working with all of the newest versions of appsmith? Or is it possible that at some time the older properties will not work anymore and we have to rewrite all the codes we have written in the past and we are still using?

The tableColumns property was an internal property that was removed in Table widget v2 as it was no longer needed. Any properties that are not exposed through the autocomplete are internal properties and might get subjected to change over the course of the widget lifespan.
However, we have created a feature request to add a new tableHeaders property and expose it. You can track the progress here: [Feature]: Add a new tableHeaders property to autocomplete in table · Issue #18066 · appsmithorg/appsmith · GitHub
Until this gets implemented, you can use the columnOrder property as a workaround.

OK, thank you very much.