#Programmatically change column ordering
1 messages · Page 1 of 1 (latest)
Hello! I'm Appsmith Support Bot, here to assist you with your queries.
To change the order of columns programmatically in Appsmith, you can manipulate the data source or the data array that populates the table. You can reorder the columns by adjusting the order of the keys in the data objects. Here's a basic example of how you might achieve this using JavaScript:
export default {
reorderColumns: (data, newOrder) => {
return data.map(row => {
let reorderedRow = {};
newOrder.forEach(key => {
reorderedRow[key] = row[key];
});
return reorderedRow;
});
}
}
You can call this function and pass your data along with the desired column order as an array of keys. For example:
{?{ JSObject1.reorderColumns(fetchData.data, ["column3", "column1", "column2"]) }?}
This will reorder the columns based on the sequence you provide. Adjust the newOrder array to insert columns between others as needed?5:1?Appsmith Documentation.pdf?.
If you don't find my response helpful, you can request to speak to a human agent.