See this playground link for an example.
The table gets sortedBy a url, rather than label. I guess I could try to hardcode something or name my fields in a way that's easy to drop url suffix, but it's a bit dirty.
Note event.detail
doesn't have a fieldLabel
property, just fieldName
.
Is there some more elegant solution? Feels like datatable should have built in sorting function that's controlled declaratively, but that's topic for another discussion :)
Edit: For now my fix is
const dataField = column && column.typeAttributes && column.typeAttributes.label
&& column.typeAttributes.label.fieldName || sortedBy
cloneData.sort(this.sortBy(dataField, sortDirection === 'asc' ? 1 : -1))