[CONNECT C++] Add Formatting to a Report Column

The SDK example Annotations\ReportsExample shows how to create a report definition programmatically: create a set of ColumnDefinitionNodes...

ColumnDefinitionNodePtr columnNode = groupNode.CreateColumnDefinition (columnName, -1);
ReportColumnAccessorList accessors;
accessors.push_back (ReportColumnAccessor (QualifiedECAccessor (schemaName, className, accessString)));
columnNode->SetAccessors (accessors);

What is not shown, and what I can't find mentioned in MicroStationAPI help, is how to apply formatting to a report column.

Parents
  • By formatting are you referring to column values sort options (SetColumnName, SetAscending, SetCaseSensitive, SetApplyBeforeFormatting, and SetHideDuplicateValues) performed within ECReportNode (..\include\DgnPlatform\ECReportNode.h+109)?

    Thank you,
    Bob



  • Unknown said:
    By formatting are you referring to column values sort options?

    No, I mean formatting.  When annotating an element with Item Types, for example, we can create formatted text that follows the rules defined in the Mstn Property Formatter schema.

    When creating a Report, those same options are not available, at least programmatically.  When creating the TextBlocks to make that label, I use this, which is building a class instance of a formatter using the Mstn Property Formatter schema (thanks to Paul Connelly for his help in achieving this)...

    WCharCP                                 AreaClassName   { L"AreaClass" };
    ECN::ECClassCP                          formatClass     { formatSchema->GetClassCP (AreaClassName) };
    StandaloneECEnablerP                    enabler         { formatClass->GetDefaultStandaloneEnabler () };
    StandaloneECInstancePtr                 localInstance   { enabler->CreateInstance () };
    if (localInstance.IsValid ())
    {
      WCharCP                               PropUnits       { L"Units" };
      ECValue                               units           { nUnits };
      localInstance->SetValue (PropUnits, units);
      WCharCP                               PropAccuracy    { L"Accuracy" };
      ECValue                               valAccuracy     { accuracy };
      localInstance->SetValue (PropAccuracy, valAccuracy);
      WCharCP                               PropUnitDecorator { L"UnitDecorator"	};
      ECValue                               valDecorator      { decorator };
      localInstance->SetValue (PropUnitDecorator, valDecorator);
    }
    // use localInstance to create TextBlock

    I don't see anywhere in the API how to apply similar formatting to a Report column.  What I'm expecting or hoping is that there's a facility to assign a similar format to a column, and values assigned to that Report column will use that formatter when creating a table.  Perhaps I'm assuming too much?

     
    Regards, Jon Summers
    LA Solutions

  • Jon,

    You will not find a convenient API for this.
    The Reports dialog uses the XDataTree API to do it.
    Basically the formatting is stored as an extra ECInstance on the column definition's XDataTreeNode.
    As you've probably noticed, the XDataTree API is not especially user-friendly.
    You *can* use that API to add/remove formatting - but the Reports dialog has lots of extra validation logic on top of that to ensure the formatting options specified are compatible with the column's data type.
    You may prefer to request that a convenient API be provided on ColumnDefinitionNode.

    Regards,
    Paul
  • Unknown said:
    As you've probably noticed, the XDataTree API is not especially user-friendly

    I was keeping quiet about that The lack of a decent EC formatting API and its complete absence for formatting tables is a serious inconvenience...

    Unknown said:
    You may prefer to request that a convenient API be provided on ColumnDefinitionNode

    How does one go about requesting an enhancement to the API?

     
    Regards, Jon Summers
    LA Solutions

Reply Children