Valid from List & Label 19
Report parameters are a very good way to let the user pre-filter the data interactively or to change it later in the preview. However, in order to be able to make a certain preselection of the available report parameters in your own code, the so-called DOM (Document Object Model) from List & Label can be used. The DOM-API is available from the Professional Edition. The following section uses simple code examples to illustrate how to do this.DOM with C++:
After starting the print/export, DOM is used to load the currently used project and access its report parameters.
...
::LlPrintWithBoxStart(m_hJob, LL_PROJECT_LIST, sFileName,
LL_PRINT_EXPORT,
LL_BOXTYPE_STDABORT, hWnd, _T("Printing...")
);
HLLDOMOBJ hProj = NULL;
::LlDomGetProject(m_hJob, &hProj);
HLLDOMOBJ hReportParameterList = NULL;
::LlDomGetObject(hProj, _T("ReportParameters"), &hReportParameterList);
HLLDOMOBJ hReportParameter = NULL;
::LlDomGetSubobject(hReportParameterList, 0, &hReportParameter);
::LlDomSetProperty(hReportParameter, _T("CurrentContents"), _T("Content"));
...
DOM with C#:
When using the. NET component, the contents of the report parameters can be controlled via an event by accessing the current project in the event.
...
LL.ReportParametersCollected += OnReportParametersCollected;
LL.Export(new ExportConfiguration(LlExportTarget.Pdf, @"C:\temp\Report.pdf", "Test.lst"));
...
private void OnReportParametersCollected(object sender, ReportParametersCollectedEventArgs e)
{
// This is not required to set a simple value for a parameter,
// for report parameters with a fixed set of available options (a list of checkboxes in the preview)
// but the possible options can be determined via the event arguments:
// e.ReportParameters[...].Choices
// In case of errors, this event is triggered again and the error message can be retrieved via:
// e.NeedDataErrorClient
// Here, the currently loaded project is accessed via DOM
using (var project = new ProjectList(sender as ListLabel))
{
project.GetFromParent();
// The report parameters can be determined here
foreach (ReportParameter param in project.ReportParameters)
{
// And set the value for a particular parameter
if (param.Identifier == "@MyReportParameter")
{
param.CurrentContents = "Content";
}
}
}
// With "Continue" the export is continued, with "Abort" you can cancel it here
// also if e. g. not all necessary values were available
e.ReturnType = ReportParametersCollectedReturnType.Continue;
}
...
IDKBTE001350 KBTE001350