Issues in displaying tabular information in report with dynamic data source

266
4
03-20-2024 06:32 AM
Sai_PhaneendraPoludasu2
New Contributor III

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

  1.  The column headers does not render the display name that was set
  2. Column size is auto set which trims the column header instead of wrapping
  3. Unable to display more than 6 columns (not in the sample)

Attached a sample project of what I have tried along with the datasource.

Any guidance or reference is much appreciated.

0 Kudos
4 Replies
GKmieliauskas
Esri Regular Contributor

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);
            }
        }
0 Kudos
Sai_PhaneendraPoludasu2
New Contributor III

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.

0 Kudos
Sai_PhaneendraPoludasu2
New Contributor III

@GKmieliauskas Any thoughts ?

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

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:

Wolf_0-1711487984566.png

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.