Enable default sort on detail load and allow users to manual sort

Dear Community, 

 

As per the link : https://community.creatio.com/questions/sort-detail-page-load

we implemented sorting by date time when the detail loads the first time. 

Method 1 

addGridDataColumns: function(esq) {
	this.callParent(arguments);
 
	// add sorting column
	var ModifiedOnColumn = esq.addColumn("ModifiedOn", "ModifiedOn");
	ModifiedOnColumn.orderPosition = 0;
	ModifiedOnColumn.orderDirection = Terrasoft.OrderDirection.DESC;
}

Method 2 : 

getGridDataColumns: function() {

                var gridDataColumns =  {

                    "ModifiedOn": {path: "ModifiedOn", orderPosition = 0

                    orderDirection: Terrasoft.OrderDirection.DESC}

                    }; 

                return gridDataColumns;

            }

Observations : if orderposition is mentioned, manual sort by user does not happen.

Removing order position and implementing any of the above methods, sorts the records, but once user does a manual sort, say by Name, the next time user logs in, the detail records are sorted by Name and not by the default sort condition "ModifiedOn"

 

Is there a way to enforce sort when user logs in and also allow manual sort by user?

 

Thanks in advance!

Like 0

Like

7 comments

Hello Shivani,

 

It happens since the sorting state for detail is saved in the SysProfileData table and each time a user opens a detail the correspondent sorting state is taken from the SysProfileData table.

 

You need to create a trigger in the system that could automatically remove a record about detail records sorting order in the SysProfileData table upon each login to the application.

 

To find a needed record you need to use two key points:

 

1) Use the "ContactId" column value to find records for some particular system user (references a contact of a system user)

2) Use the "Key" column and put the name of a detail

 

Here is an example of a query:

 

select * from SysProfileData where [Key] like '%Schema0bbbd1fe%' and ContactId in (select ContactId from SysAdminUnit where Name = 'input the name of a system user')

What you need to do is to drop a record found by the query, but upon each login to the system. For this purpose you can create a trigger that will be triggered upon changing the "LoggedIn" column value from the "SysAdminUnit" table.

 

Best regards,

Oscar

Oscar Dylan,

Thank you for your response, Oscar!

Oscar Dylan,

Hi Oscar. Is there a way to disable this 'Sort order memory' either at a detail level or user level or application level? What if users did not want their sort order to be remembered and pre-loaded?

M Shrikanth,

 

Hello,

 

In this case you will need to study the BaseDataView and check a particular place in the schema where UserProfile request is generated upon modifying the sorting order of a detail column and override the method where it happens so not to save the UserProfile state.

 

Best regards,

Oscar

Oscar Dylan,

 I understand Oscar. It would be laborious to identify all such details and override sending of the UserProfile request. I was looking at a master switch which will toggle whether this sort order is 'remembered' or not. I infer that such a feature is not available as of now

M Shrikanth,

 

No there is no such a toggle or a setting or a feature. This is all the logic in the BaseDataView that needs to be overridden in case it's not needed.

 

Best regards,

Oscar

Oscar Dylan,

Thanks Oscar. Appreciate your input. 

Show all comments