
There are a few different options for setting a sort for details in Creatio. You can add a default sort column and direction to a detail added to a page schema, or you can add the sort in the detail schema so the sort will apply to the detail no matter where it is used. Let’s take a look at both options.
Adding the Sort to the Detail
If you want to always ensure the detail has your sort column and direction, no matter where you use the detail, the best route is to add it in the detail schema. Then, no matter what page you add the detail on, the sort is built into the detail schema itself and will apply anywhere. To do this, we’ll open the detail schema code in the configuration, then override the onGridDataColumns function by adding the following to the methods:
addGridDataColumns: function(esq) { this.callParent(arguments); // add the column we want to sort by to the EntitySchemaQuery passed in // We can use any column, whether or not it is in the column layout for the detail // in this sample we'll be sorting on the CreatedOn column in descending order var createOnCol = esq.addColumn("CreatedOn"); createOnCol.orderPosition = 0; createOnCol.orderDirection = Terrasoft.OrderDirection.DESC; }
Adding the Sort to the Page the Detail is On
If the detail is on a page and you want to add a sort to it, you can do it in the details page of the page code. This method is useful if you don’t need or want to override the detail schema, for cases when the detail itself is in another package. To do this, open the page code and locate the details section. You’ll see the detail there as follows (this is what is added by the page wizard when you add a detail normally):
details: /**SCHEMA_DETAILS**/{ "UsrMyDetail": { "schemaName": "UsyMyObject", "filter": { "masterColumn": "Id", "UsrAccount" } } }
Add the sort column and direction as shown below (again, in our sample we’ll be sorting on the CreatedOn column in descending order):
details: /**SCHEMA_DETAILS**/{ "UsrMyDetail": { "schemaName": "UsyMyObject", "filter": { "masterColumn": "Id", "UsrAccount" }, "sortColumn": "CreatedOn", "sortColumnDirection": Terrasoft.OrderDirection.DESC, "sortColumnIndex": 0 } }
Either method should give you the results you’re after, however, also keep in mind that the user can click on column headers to sort the detail as well. The user’s specified sort will take precedence over what you specify in the code.
Subscribe To Our Newsletter
Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!
You have Successfully Subscribed!