Sorting dynamic fields

Hello!
I'm trying to create a table whose columns are date. The number of columns is dynamic and I want these dates to be sorted.
I couldn't find a way to sort dynamic columns in the new table, so I'm trying to use the setting in the legacy table, but it doesn't work. (no response)


image

Hi @Mark_Shcherbakov, I'm happy to help! :slightly_smiling_face:

If the output of 'T_SettingColumn.value' is an array, we could use a Transformer to format our data in a sorted way.

The JS in the transformer would look something like this:

const sortedData = [
  {{ T_SettingColumn.value }}.find(column => "column1" in column),
  ...{{ T_SettingColumn.value }}.filter(column => !("column1" in column))
    .sort((a, b) => new Date(a[Object.keys(a)[0]].name) - new Date(b[Object.keys(b)[0]].name))
];

return sortedData

This is assuming that 'column1' will always be name, we may need to refactor if that is not the case.

The last step would be to update the "Column settings" of our component to {{ TransformerName.value }}