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
110
Problem with group by column order on Excel export
posted

I have two problems (one may be a bug). 

I would like to be able to programmatically groupby two columns and then sort the results by a third column.  I am able to get the two columns to do the outlook groupby when the grid loads but the results when expanded are not being sorted by the third column.

In other words, I have Clinics which contain many Doctors (PCP in my code below) which have many Patients.  When the grid loads I want to groupby Clinic and then Doctor and then display the PatientIDs in order.  I can get the two Outlook groupbys to work but I can't get the PatientIDs to sort.  Please see my code below and let me know if I'm missing anything to specify the correct groupby and sort.

Problem #2 arises when I try to export to Excel.  When I have the groupby rolled up in the webgrid by Clinic and then Doctor, the Excel spreadsheet reverses the groupby column order, displaying the groupby rolled up by Doctor and then Clinic.  If I reverse the order of the groupby columns in the webgrid to Doctor first and then Clinic, the Excel spreadsheet again reverses the column order and displays the groupby as Clinic and then Doctor.  So I can't get the Excel export to match what's in the webgrid when I groupby two columns programmatically.  Any idea how I fix this?  It only happens when I set the groupby programmatically.  If I comment out the below code and manually drag the columns to do the two-column groupby, the Excel export works as expected.  Thanks...

The relevant code:

// Default to Grouping by Clinic & PCP and then sort by PatientID
this.UltraWebGrid1.DisplayLayout.ViewType = Infragistics.WebUI.UltraWebGrid.ViewType.OutlookGroupBy;
int clinicIndex = getColumnIndex(ref this.UltraWebGrid1, "Clinic_value");
int pcpIndex = getColumnIndex(ref this.UltraWebGrid1, "PCP_value");
int patientIDIndex = getColumnIndex(ref this.UltraWebGrid1, "PatientID");
UltraGridColumn clinicColumn = this.UltraWebGrid1.DisplayLayout.Bands[0].Columns[clinicIndex];
UltraGridColumn pcpColumn = this.UltraWebGrid1.DisplayLayout.Bands[0].Columns[pcpIndex];
UltraGridColumn patientIDColumn = this.UltraWebGrid1.DisplayLayout.Bands[0].Columns[patientIDIndex];
clinicColumn.IsGroupByColumn = true;
pcpColumn.IsGroupByColumn = true;
this.UltraWebGrid1.Bands[0].SortedColumns.Add(clinicColumn);
this.UltraWebGrid1.Bands[0].SortedColumns.Add(pcpColumn);
this.UltraWebGrid1.Bands[0].SortedColumns.Add(patientIDColumn);

Parents Reply Children
No Data