Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1155
Group and Ungroup Programatically Expand by group Text vale
posted

I have managed to group my datagrid using the below found elsewhere on this site.

Problem: How to expand an item in the group by text value after the items have been grouped?

Issues: There is not such event as AfterGrouping and the myGrid.Grouped event does not fire if you group things programmatically.

"

Field fld = this.AreaUnitDetails.FieldLayouts[0].Fields[4]; // Type
            FieldSortDescription fsd = new FieldSortDescription();
            fsd.Field = fld;
            fsd.Direction = ListSortDirection.Ascending;
            fsd.IsGroupBy = true;           
            this.AreaUnitDetails.FieldLayouts[0].SortedFields.Add(fsd); "

            // Check the groups

            bool gbsf = this.AreaUnitDetails.FieldLayouts[0].HasGroupBySortFields;         
           
            var temp = this.AreaUnitDetails.Records.DataPresenter.GetRecordsInView(true);

 

Ok, so the problem begins....

1. This code must return for the grid to actually become grouped.

2. How do I expand one of the grouped items after the collection has been grouped?

3. There is no such event as after grouping so there is nothing to act on.

4. I am performing this from the Display CTs button.

Attached is a view of my grouped collection. I want to expand the "CT" items by the same label after the records have been grouped - without user interaction.

 

Thanks,

Glenn Long

Parents
  • 69686
    Verified Answer
    posted

    Hello Glenn,

    You are right, there is no specific event with name like "AfterGrouping", but you can use couple of other events.

    You can use the InitializeRecord event. This will fire, because records will be reinitalized and become GroupByRecords, so you can check if the record is GroupByRecord and set IsExpanded=true is needed.

    You can also use RecordsInViewChanged event, which will also fire. Again, you can get the records by GetRecordsInView method and see if they are groupbyrecords and expand the one you need.

    Let me know if you have questions on this.

Reply Children
No Data