cancel
Showing results for 
Search instead for 
Did you mean: 

Group Headers Missing in Report

Former Member
0 Kudos

Post Author: CHTClay

CA Forum: .NET

Ok, this is driving me full goose bozo. Using RAS SDK I can add grouping to my reports all day long, however, when I run the report the group header is blank. The groups show up in the group tree, just no text in the group field. Here is the code I use to group:

private void AddGroup(ISCDReportClientDocument oDoc, string TableName, string FieldName)

{

CrystalDecisions.ReportAppServer.DataDefModel.Group oGroup;

CrystalDecisions.ReportAppServer.DataDefModel.Table oTable;

ISCRTable oISCRTable;

Field oField;

oGroup = new CrystalDecisions.ReportAppServer.DataDefModel.GroupClass();

oISCRTable = oDoc.Database.Tables.FindTableByAlias(TableName);

oTable = ((CrystalDecisions.ReportAppServer.DataDefModel.Table)oISCRTable);

oField = ((Field)oTable.DataFields.FindField(FieldName, CrFieldDisplayNameTypeEnum.crFieldDisplayNameName, CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleUserDefault));

oGroup.ConditionField = oField;

oDoc.DataDefController.GroupController.Add(-1, oGroup);

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Post Author: Ted Ueda

CA Forum: .NET

You'll actually have to create a FieldObject and place it in the GroupHeaderSection.Sincerely,Ted Ueda

Answers (2)

Answers (2)

Former Member
0 Kudos

Post Author: CHTClay

CA Forum: .NET

The Solution. Added the code that is bold and italic:

CrystalDecisions.ReportAppServer.ReportDefModel.ReportDefinition oRepDef;

CrystalDecisions.ReportAppServer.ReportDefModel.Section oSec2;

CrystalDecisions.ReportAppServer.DataDefModel.Group oGroup;

CrystalDecisions.ReportAppServer.DataDefModel.Table oTable;

ISCRTable oISCRTable;

Field oField;

CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject oFieldObject;

oRepDef = new CrystalDecisions.ReportAppServer.ReportDefModel.ReportDefinitionClass();

oSec2 = new CrystalDecisions.ReportAppServer.ReportDefModel.SectionClass();

oGroup = new CrystalDecisions.ReportAppServer.DataDefModel.GroupClass();

oFieldObject = new FieldObjectClass();

oISCRTable = oDoc.Database.Tables.FindTableByAlias(TableName);

oTable = ((CrystalDecisions.ReportAppServer.DataDefModel.Table)oISCRTable);

oField = ((Field)oTable.DataFields.FindField(FieldName, CrFieldDisplayNameTypeEnum.crFieldDisplayNameName, CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleUserDefault));

oGroup.ConditionField = oField;

oDoc.DataDefController.GroupController.Add(-1, oGroup);

oRepDef = oDoc.ReportDefinition;

oSec2 = oRepDef.get_GroupHeaderArea(ha).Sections[0];

oFieldObject.Kind = CrReportObjectKindEnum.crReportObjectKindField;

oFieldObject.FieldValueType = oField.Type;

oFieldObject.DataSource = oField.FormulaForm;

if (oField.Type == CrFieldValueTypeEnum.crFieldValueTypeDateTimeField)

oFieldObject.FieldFormat.DateTimeFormat.DateTimeOrder = CrDateTimeOrderEnum.crDateTimeOrderDateOnly;

if (oField.Type == CrFieldValueTypeEnum.crFieldValueTypeInt32sField)

oFieldObject.Format.HorizontalAlignment = CrAlignmentEnum.crAlignmentLeft;

oDoc.ReportDefController.ReportObjectController.Add(oFieldObject, oSec2, 0);

Former Member
0 Kudos

Post Author: CHTClay

CA Forum: .NET

Ted,

Thanks very much for your reply. I tried adding a Field object, which does show up, but, sad to say, I have no idea how to get the value of the group header into it. Any suggestions?