I have a smart table, with some custom columns inside it. I would like to sort the table initially based on a certain field, how do I achieve it?
Till now I have tried the following, but it didn't work.
var oSmartTableBatches = this.getView().byId("sapAffectedBatchesSmartTable2");
oSmartTableAlerts.applyVariant({
sort: {
sortItems: [{
columnKey: "FieldName",
operation: "Descending"
}]
}
});
I have also tried annotating the entity set with Presentation Variant
<Annotation Term="com.sap.vocabularies.UI.v1.PresentationVariant">
<Record>
<PropertyValue Property="SortOrder">
<Collection>
<Record>
<PropertyValue Property="Property" PropertyPath="FieldName"/>
<PropertyValue Property="Descending" Boolean="true"/>
</Record>
</Collection>
</PropertyValue>
</Record>
</Annotation>
I am using odata v2 model.
I also tried using beforeRebindTable function add a sorter, however it breaks the table personaliation dialog, and grouping and filtering doesn't work on table anymore.