cancel
Showing results for 
Search instead for 
Did you mean: 

Group Heading not show in group header

Former Member
0 Kudos

Hi to all,

i create a dynamic crystal report. when i set grouping through code, data are grouped in crystal report but the group heading not show in group header. i use this code. i more under stand i upload screen short. please help if possible.

Fields ffdd = clientdocument.DatabaseController.Database.Tables[0].DataFields;

Group oGroup;

Table oTable;

ISCRTable oISCRTable;

Field oField;

oGroup = new GroupClass();

//Find the table or stored procedure in the table collection based on the name

oISCRTable = clientdocument.DatabaseController.Database.Tables[0];

//oISCRTable = clientdocument.Database.Tables.FindTableByAlias("tblLov");

oTable = ((Table)oISCRTable);

            //Cast this field reference to a Field object

            oField = ((Field)oTable.DataFields.FindField("ReturnColumn", CrFieldDisplayNameTypeEnum.crFieldDisplayNameName,

                CrystalDecisions.ReportAppServer.DataDefModel.

            CeLocale.ceLocaleUserDefault));

            //Set the Field object as the group condition

            oGroup.ConditionField = oField;

            //Add the group to the report

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

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello,

I'm install SP 11 RC build right now so can't test but I believe you need to set the Conditional formula also, set it to the field or test object as you would in CR Designer.

Don

0 Kudos

Here's how to get the info:

foreach (CrystalDecisions.ReportAppServer.DataDefModel.Group resultField in rptClientDoc.DataDefController.DataDefinition.Groups)

{

    textBox1 = resultField.ConditionField.FormulaForm.ToString();

    btnReportObjects.Text += textBox1;

    btnReportObjects.AppendText(" 'End' \n");

    ++flcnt;

    btnCount.Text = flcnt.ToString();

    //// Do NOT delete - how to change date filtering for groups based on a date field

    //CrystalDecisions.ReportAppServer.DataDefModel.Group oldGroup;

    //CrystalDecisions.ReportAppServer.DataDefModel.Group newgroup;

    //CrystalDecisions.ReportAppServer.DataDefModel.DateGroupOptions dgOpts = new CrystalDecisions.ReportAppServer.DataDefModel.DateGroupOptions();

    //if (resultField.ConditionField.FormulaForm == "{Orders.Order Date}")

    //{

    //    dgOpts.DateCondition = CrystalDecisions.ReportAppServer.DataDefModel.CrDateConditionEnum.crDateConditionMonthly;

    //    oldGroup = rptClientDoc.DataDefController.DataDefinition.Groups[flcnt-1];

    //    newgroup = oldGroup.Clone(true);

    //    newgroup.Options = dgOpts;

    //    rptClientDoc.DataDefController.GroupController.Modify(oldGroup, newgroup);

    //    IsRpt = false;

    //}

}

with a bonus on how to set the condition formula to a data field

Don

Former Member
0 Kudos

Hello Don,

Thanks for replay.

i try but the problem is still, i use textobject in group header as an alternet but i can not display the grouped item name in textobject. i attached screen short for better understand. i use following code for adding textobject in group header.

TextObject gpTextObject;

            CrystalDecisions.ReportAppServer.ReportDefModel.Section gpSection;

            gpSection = clientdocument.ReportDefController.ReportDefinition.get_GroupHeaderArea(0).Sections[0];

            gpTextObject = new CrystalDecisions.ReportAppServer.ReportDefModel.TextObject();

            //Create the paragraph elements for the text Object

            Paragraphs gpParagraphs;

            gpParagraphs = new CrystalDecisions.ReportAppServer.ReportDefModel.Paragraphs();

            Paragraph gpParagraph;

            gpParagraph = new CrystalDecisions.ReportAppServer.ReportDefModel.Paragraph();

            gpParagraph.Alignment = CrAlignmentEnum.crAlignmentHorizontalCenter;

            ParagraphElements gpParagraphElements;

            gpParagraphElements = new CrystalDecisions.ReportAppServer.ReportDefModel.ParagraphElements();

            ParagraphTextElement gpParagraphTextElement;

            gpParagraphTextElement = new CrystalDecisions.ReportAppServer.ReportDefModel.ParagraphTextElement();

            //Set the text value for the text field

//Problem is here

            gpParagraphTextElement.Text = ????? ;

            gpParagraphTextElement.Kind = CrystalDecisions.ReportAppServer.ReportDefModel.CrParagraphElementKindEnum.crParagraphElementKindText;

            //fix some wierd defaults and behavior by explicitly setting default font

            FontColor gpFontColor = new CrystalDecisions.ReportAppServer.ReportDefModel.FontColor();

            CrystalDecisions.ReportAppServer.ReportDefModel.Font gpFont = new CrystalDecisions.ReportAppServer.ReportDefModel.Font();

            gpFont.Bold = true;

            gpFont.Name = "Arial";

            gpFontColor.Font = gpFont;

            gpParagraphTextElement.FontColor = gpFontColor;

            gpParagraphElements.Add(gpParagraphTextElement);

            gpParagraph.ParagraphElements = gpParagraphElements;

            gpParagraphs.Add(gpParagraph);

            gpTextObject.Paragraphs = gpParagraphs;

            //Now add it to the section

            gpTextObject.Left = 0;

            gpTextObject.Top = 1;

            gpTextObject.Width = 1911;

            gpTextObject.Height = 226;

            #endregion

            clientdocument.ReportDefController.ReportObjectController.Add(gpTextObject, gpSection, -1);

Answers (0)