Rebuild DataSources with Dictionary.Synchronize()?

Stimulsoft Reports.NET discussion
Post Reply
Andreas Tastler
Posts: 63
Joined: Fri Jul 17, 2009 5:00 am
Location: St. Gallen, Switzerland

Rebuild DataSources with Dictionary.Synchronize()?

Post by Andreas Tastler »

I have a saved report bound to a DataSource with DataTables. I also added some calculated Columns to the DataSource (some are not used in the Report).
Someday the columns of the datatable are changing (new columns will be added, existing columns will be removed). The synchronize method of dictionary will only add new columns to the datasource, but deleted columns will not be removed. How can I reset the datasource to the datatable contents in datastore? I tried to clear the dictionary before synchronizing, but then all calculated columns are gone too :-(.

Thanks
Andreas
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Rebuild DataSources with Dictionary.Synchronize()?

Post by Edward »

Hi Andreas,

Please try to use the following command for each DataSource individually:

MyDataSource.SynchronizeColumns();

Thank you.
Andreas Tastler
Posts: 63
Joined: Fri Jul 17, 2009 5:00 am
Location: St. Gallen, Switzerland

Rebuild DataSources with Dictionary.Synchronize()?

Post by Andreas Tastler »

Hi Edward

I tried to synchronize the way you suggested, but the result is the same. Columns that have been removed from the data tables will not be removed from dictionary.

Code: Select all

      _stiReport.RegData("Report-Data", ReportDataSet);
      _stiReport.RegData("Common-Data", CommonDataSet);

      foreach (StiDataSource source in _stiReport.Dictionary.DataSources)
      {
        source.SynchronizeColumns();
      }
I also tried the Method Dictionary.RemoveUnusedData but this also removes unused calculated columns. The calculated columns should not be removed.

Regards
Andreas
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Rebuild DataSources with Dictionary.Synchronize()?

Post by Edward »

Hi Andreas,

Please send a sample solution to support[at]stimulsoft.com for reproducing the issue, as I could not reproduce these wrong behaviour.

P.S. The following code can redraw the Dictionary panel if you called your code from designer:

Stimulsoft.Report.Design.Panels.StiDictionaryPanelService.GetService(this).DictionaryControl.Build((this).Report);

this - it is a designer.

Thank you.
Andreas Tastler
Posts: 63
Joined: Fri Jul 17, 2009 5:00 am
Location: St. Gallen, Switzerland

Rebuild DataSources with Dictionary.Synchronize()?

Post by Andreas Tastler »

Hello Edward

I fixed it that way: before synchronizing the dictionary I remove all columns, which are not calculated, then I call the synchronize method. In this case all calculated fields are still available.

Regards
Andreas
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Rebuild DataSources with Dictionary.Synchronize()?

Post by Edward »

Hi Andreas,

Thank you for this information.
Post Reply