Dear Community,
We would like to have a detail sorted by year and month on page load. Could you please let us know if there is any default sort on details or a client side code to achieve this?
Thanks
Shivani
Like
You can edit the page you added the detail to, then modify the details, under the details section of the page code, to add a sort column using sortColumn, sortColumnDirection, and sortColumnIndex.
Ryan
Ryan Farley,
We have a detail called contract value target in contacts section which needs to be sorted by month and year.
I tried the following in the contactsPageV2 schema.
"UsrSchema31Detail759084ab": {
"schemaName": "UsrSchema31Detail",
"entitySchemaName": "UsrContractValueTarget",
"filter": {
"detailColumn": "UsrSalesUser",
"masterColumn": "Id"
},
"sortColumn":"UsrYear",
"sortColumnDirection":Terrasoft.OrderDirection.desc,
"sortColumnIndex":0
It doesn't seem to work. Is there anything else I need to do?
Shivani Lakshman,
This is likely because you've added "desc" in lowercase and it should be uppercase (it's case-sensitive). Choices are:
- Terrasoft.OrderDirection.ASC (or a 1)
- Terrasoft.OrderDirection.DESC (or a 2)
- Terrasoft.OrderDirection.NONE (or a 0)
Ryan
Changing the edit page schema to specify sort direction did not appear to work for me, however another method which did work for me and will persist wherever the detail is used (useful if you want that) is by overriding the addGridDataColumns function in the detail schema and adding a sorted column to the Entity Schema Query like so:
addGridDataColumns: function(esq) { this.callParent(arguments); // add sorting column var createdOnColumn = esq.addColumn("CreatedOn", "CreatedOn"); createdOnColumn.orderPosition = 0; createdOnColumn.orderDirection = Terrasoft.OrderDirection.DESC; }