I was able to create a Report through ArcGIS Pro interface and access it through SDK. I am trying to show a table with 8 columns.
The datasource is dynamic and generated by manipulating the original datasource to suit the report needs. Updated the report columns uing the SDK, but seeing the following issues
Attached a sample project of what I have tried along with the datasource.
Any guidance or reference is much appreciated.
Hi,
You can set DisplayName and other CIMTableField properties after report creating:
List<string> displayNames = new List<string>() { "Project Id", "Id", "Field 1", "Field 2", "Field 3", "Field 4", "Field 5", "Field 6", };
internal async Task Execute()
{
if (FLayer == null) return;
try
{
var reportDataSource = PrepareDataSource();
var report = await CreateReportAsync(reportDataSource);
for (int i = 0; i < report.DataSource.Fields.Count(); i++)
{
var cimField = report.DataSource.Fields.ElementAt(i);
cimField.DisplayName = displayNames[i];
if (i == 0) cimField.Group = true;
if (i == 3 || i == 5 || i == 7)
{
cimField.IsVisible = false;
}
}
MessageBox.Show("Report created successfuly.");
}
catch (Exception ex)
{
MessageBox.Show("Failed to create report. Error" + ex.Message);
}
}
Thanks @GKmieliauskas for sharing the code snippet. I tried this and it did not work for me, the display name is not reflected in the final output.
@GKmieliauskas Any thoughts ?
I tested the "DisplayName", "IsVisible", and the "FieldOrder" properties of CIMReportField and i was not able to get any of these properties to work as expected. Also, the ‘ReportDataSource’ method doesn’t use the ‘useSelectionSet’ parameter as documented. When i set the parameter to false the report still only shows the selected features.
I asked the Report API dev team to take a look at this, however, in the meantime i would recommend using the Alias in the Fields definition:
To hide a column just don't add the column to the CIMReportField array. To change the order you have to re-arrange the order in your CIMReportField array. And in order to add all records to your report you need to clear all selected features before you run (export/preview) the report. If the selected features are not cleared only the selected features will appear in your report.
I reply on this thread after i hear back from the Report API dev team.