Category: Widget
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How Do I Get the Column Names of a Table Widget?

Issue

I am having trouble getting an array with the column names from a Table widget in Appsmith. I tried using the property "tableColumns" but it doesn't seem to exist in the newer version of the Table widget. I asked for help in the forum and was given a workaround using "columnOrder" instead. However, I learned that internal properties might change over time, so there is a feature request to add a new property called "tableHeaders".

Resolution

To get an array of column names in a Table widget you can use the following snippet:

Object.keys(Table1.tableData[0])

This works because each row from the table data is a JSON object where the keys are column names and the values are values.