Can we mix static sorting with dynamic sorting?

I need to have static sorting by default by certain colums but also dynamic one when users click on the table column. Is it possible?

I've tried but seems not working

Hi Eric,

It's possible. In the Sorting of your aggregate you use the function:

List_SortColumn_GetOrderBy(PersonTable.Id, "{Person}.[Name]")

to do dynamic sort. The second parameter of that function is the Attribute (or Attributes) of the Sorting by default.

Cheers,

José

Hi Eric, 

Jose is correct by using above function you can set static sorting by default same time you can define dynamic sorting on certain colums using List_SortColumn event their in RichWidgets by proving column name as string.

I am attaching the sample oml here for your reference.

Sachin

Sorry I was in rush maybe it's not clear.

I have 5 columns lets say colA, colB, colC, colD and colE

First time display I want it sorted by colC, colB, colA

But also I want to let users have dynamic sort by clicking the table column name...so in sorting property of the aggregate I have multiple sorts....

3 sort is static sort (colC, colB, colA)

1 dynamic sort using technique you mentioned above

List_SortColumn_GetOrderBy(PersonTable.Id, "{Person}.[Name]")

But dynamic sort seems not working out.

Hi Eric,

It should work, I also added three static sorting and dynamic as well using the same function 

List_SortColumn_GetOrderBy(EmployeeTable.Id, "{Employee}.[Name] ASC, {Employee}.[Contact] ASC,{Employee}.[Email] ASC")

It's working for me. Please check the sample oml that I am attaching.

Hi Eric,

Imho the main problem here is not a technical one, but a functional one: do you want to support both the manual ordering by column, and the "static" order after the manual order has been set, and if so, what should the user click to achieve this?

Technically, there's also a List_SortColumn_SetOrderBy to set the initial values for the columns, so if you do not need the "static" ordering after a manual ordering, you could use that (and, in case you do need it and have some button or the like, you could use it again for that).

Solution

Thanks for Sachin and Kilian for the answer

Solution

Great to hear we could help you Eric!

Sachin Mahawar wrote:

Hi Eric,

It should work, I also added three static sorting and dynamic as well using the same function 

List_SortColumn_GetOrderBy(EmployeeTable.Id, "{Employee}.[Name] ASC, {Employee}.[Contact] ASC,{Employee}.[Email] ASC")

It's working for me. Please check the sample oml that I am attaching.

Hi Sachin Mahawar,

If I use Desc insteading of Asc It's not working.

List_SortColumn_GetOrderBy(EmployeeTable.Id, "{Employee}.[Name]DESC, {Employee}.[Contact] DESC,{Employee}.[Email] DESC")

Thanks,

Ronan T.


Hi Ronan,

What do you mean by "not working"? Is the sort order wrong, or do you get errors?

Kilian Hekhuis wrote:

Hi Ronan,

What do you mean by "not working"? Is the sort order wrong, or do you get errors?

Hi Kilian Hekhuis,

I am not getting any errors but it is not getting sorted in descending order but in ascending order

Thanks,

Ronan T.



Hi Ronan,

Sorry, I was confused a bit (for a reason I'll explain below). The current version of SortRecordList has a parameter, "isAscending" that determines the sorting order for all Attributes in the sort. You cannot specify a per-Attribute sort like you did (anything after a valid Attribute is ignored).

The reason I was momentarily confused is because I once cloned SortRecordList, and I implemented exactly that (i.e. a per-Attribute sort), so at first glance what you wrote seemed perfectly normal.

Is it possible to make your solution available? I really need it.


Hi Elizabeth,

Find it attached. I can give no support on it, so it's provided as-is.

Hello

Thank you very much, I have saved it and tried to upload it to the development area, but it says that can only use things from Forge. Do you perhaps want to upload it to Forge?

regards

Here's an OAP that should be publishable.