Question: I want to modify the record count display for grouped/sorted items
I have a button which groups and expands a certain item based on the Description - ok easy enough.
Now, I am checking each row displayed to see if it has a certain value in a column, say > 0. If not I collapse the visible row. At the same time I want to reduce by 1 the number of records shown as ChildRecords of the group. Is it possible to modify that count.
Bottom line: If a record doesn't meet a criteria, it doesn't get displayed. Also I don't want the user thinking there are more records in the group than which are actually displayed.
Clear? Below is where I sort out the records. All works well here. Obviously I can't set the readOnly Count property, but in pseudo code that's what I want to accomplish.
Regards,
Glenn Long
void AreaUnitDetails_RecordsInViewChanged(object sender, Infragistics.Windows.DataPresenter.Events.RecordsInViewChangedEventArgs e) { Infragistics.Windows.DataPresenter.Record[] gbr; gbr = this.AreaUnitDetails.GetRecordsInView(false); foreach (Infragistics.Windows.DataPresenter.Record rec in gbr) { if (!rec.IsExpanded && rec.Description.StartsWith("CT")) { rec.IsExpanded = true; var children = rec.ViewableChildRecords.ToList(); foreach (Record child in children) { if (((ASEngine.BusinessObjects.Entities.UnitDetail)(((Infragistics.Windows.DataPresenter.DataRecord)(child)).Cells.Record.DataItem)).RegMW.Value == 0) child.Visibility = Visibility.Visible; //rec.ViewableChildRecords.Count = rec.ViewableChildRecords.Count; // Decrement count Displayed by 1. } } } }
Picture: As you can see the group CT has 4 records by count but none displayed as I have filtered them out. I want that count to show 0 or whatever is left in the list.
Thanks Alex,
That'll do it. Of course nothing is easy. One needs to find the interested group, pull out the label get the number of records involved, reduce that number and then format the label to make it readable. For exactly 1 record, I display Item rather than Items.
Glenn
void AreaUnitDetails_RecordsInViewChanged(object sender, Infragistics.Windows.DataPresenter.Events.RecordsInViewChangedEventArgs e) { Infragistics.Windows.DataPresenter.Record[] gbr; gbr = this.AreaUnitDetails.GetRecordsInView(false); GroupByRecord gr = null; try { for (int groups = 0; groups < this.AreaUnitDetails.Records.Count; groups++) { if (this.AreaUnitDetails.Records[groups].Description.StartsWith("CT")) { gr = this.AreaUnitDetails.Records[groups] as GroupByRecord; } } foreach (Infragistics.Windows.DataPresenter.Record rec in gbr) { if (!rec.IsExpanded && rec.Description.StartsWith("CT")) { rec.IsExpanded = true; var children = rec.ViewableChildRecords.ToList(); int totalNumRecs = children.Count; foreach (Record child in children) { if (((ASEngine.BusinessObjects.Entities.UnitDetail)(((Infragistics.Windows.DataPresenter.DataRecord)(child)).Cells.Record.DataItem)).RegMW.Value == 0) child.Visibility = Visibility.Collapsed; totalNumRecs = totalNumRecs - 1; if (totalNumRecs == 1) { gr.Description = "CT (" + totalNumRecs + " Item)"; } else { gr.Description = "CT (" + totalNumRecs + " Items)"; } } } } } catch (Exception ex) { Logger.LogException(LogSourceType.ClientApplication, ex); } }
Hello,
This count is the Description property of the GroupByRecord, so you can modify that. Something like this:
GroupByRecord gr = xamDataGrid1.Records[0] as GroupByRecord;
gr.Description = "3 Items";