Symptom
How to change Group Options in RAS SDK based on a Date field
Environment
Crystal Reports Developer for Visual Studio
Resolution
Sample code on how to change the date condition grouping.
Note:
- btnReportObjects is a text box to simply display the collection and results.
- IsRpt is a flag used to set the viewer to ReportDocument or ReportClientDocument ( RAS ) object.
btnReportObjects.Text = "";
flcnt = 0;
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();
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;
}
}
Keywords
KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem