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
1921
Count in GroupBy Record for lower level
posted

Hi,

Count of group (Second & Third) showing 2 items.

I want to show count of all the items below that category.

like Second (50 items) and Third (51 items) . What i have to do?

Regards,

Ramesh.P

 

 

 

 

 

Parents
  • 54937
    Verified Answer
    Offline posted

    Currently the Items count is a count of the direct children and not a deep count of the descendant datarecords. You may want to submit a suggestion for adding this. In the interim you would probably need to handle the InitializeRecord event and change the Description of the GroupByRecords. e.g.

    private void grd_InitializeRecord(object sender, InitializeRecordEventArgs e)
    {
    GroupByRecord gbr = e.Record as GroupByRecord;
     
    if (null != gbr)
    {
    int count = CountDataRecords(gbr);
    gbr.Description = string.Format("{0} ({1} items)", gbr.Value, count);
    }
    }
     
    internal static int CountDataRecords(GroupByRecord record)
    {
    int count = 0;
     
    foreach (Record child in record.ViewableChildRecords)
    {
    if (child.VisibilityResolved == Visibility.Collapsed)
    continue;
     
    GroupByRecord gbrChild = child as GroupByRecord;
     
    if (null != gbrChild)
    count += CountDataRecords(gbrChild);
    else
    {
    DataRecord dr = child as DataRecord;
     
    if (null != dr && dr.DataItem != null)
    count++;
    }
    }
     
    return count;
    }

     

Reply Children
No Data