Turn off grouping in ObjectListView Sort rotations

I am struggling to find information on a myriad of small issues that I start to face since integrating ObjectListView into my application. I must admit I love control and it takes a lot of work for me to be in control of everything I need.

However, among the several problems I've encountered so far is that if I turn off grouping for individual columns, it no longer allows those columns to be sorted.

For example, my ListView control has an ID, summary, location, etc. etc. I am currently grouping by ID because I attach a unique footer to each ID and it looks good. But when I click on "Summary" or "Location" it groups all items by "Summary or Location" and so I end up with the group header but the footer is larger because the footer no longer matches the ID.

What I want to achieve is that the user can click on any other column, but still maintain a group by id and thus maintain a footer against each item. I want the items to be sorted, not grouped, but as mentioned, when I turn off the grouping against each column, it turns off the sorting feature.

UPDATE

Basically, looking at the screenshot below, I want to be able to click the priority column header (for example) to sort the list of objects by priority, but still keep the Group ticket (with group details). And basically can click on any column header to sort the list, but keeping the grouping by tickets.

enter image description here

I intercepted the OLV_BeforeCreatingGroups event to add:

e.Parameters.GroupByColumn = Ticket_ID

      

Now it looks like I keep my ticket grouping no matter which column header I click, but now I have lost the sorting functionality.

+3


source to share


1 answer


Try setting AlwaysGroupByColumn

as column TicketId. This will do the trick :)

Second try:

Thanks for the screenshot. I think I understand what you want. You are hoping that clicking on the title will sort the groups themselves. This is not the default behavior, which is to sort the rows within each group.



To do what you ask:

  • Listen for the event BeforeCreatingGroups

    and fill in the property GroupComparer

    in the event arguments block. This comparator controls the ordering of the groups.

  • The default group order is based on OLVGroup.SortValue

    . This way you can set a delegate GroupFormatter

    and change SortValue

    for each group so that they are ordered the way you want.

In any case, you will need to use PrimarySort

and PrimarySortOrder

to find out which column the user last clicked on.

0


source







All Articles