merge data from multiple tables of dataset using NRichTextViewWithCommandBars


https://www.nevron.com/Forum/Topic12386.aspx
Print Topic | Close Window

By Mike Willis - 6 Years Ago
I am using Nevron Open Vision for .NET Enterprise 2017.1

I have a requirement to merge data from multiple tables in a dataset (c# DataSet class).
Additionally to merge all rows from a table in the dataset.
Does RichTextView support this type of merging/

If not can i write a custom mailmerge class derived from NMailMerge and NDataSource?
Or
Can i override or add custom types to the Insert Field dialog , and process these fields myself?

Thanks in advance
Mike Willis


By Mike Willis - 6 Years Ago
Was also looking at this as a solution?
When needed you can easily add support for more formats by implementing the abstract NDataSourceFormat class and registering your data source format using its static Register method.
http://helpopenvision.nevron.com/#MailMergeDataSources.html
Mike
By Nevron Support - 6 Years Ago
Hi,

The NOV rich text view uses the data rows from a single data table for mail merge. If you want to merge data rows from multiple data tables it is best to merge them into a single data table first and then pass this merged data table as data source for mail merge to the NOV rich text view. You can do this by creating a class that inherits NMailMergeDataSource, overriding its GetDataTable method to return your merged data table and assigning an instance of this class to the DataSource property of the rich text document block's mail merge object like shown below:

richTextView.Content.MailMerge.DataSource = dataSource;


Please note that Nevron Open Vision uses its own data API (i.e. custom implementation of data sets and data tables), which is the only way to make the data layer of your application truly cross-platform. For more information about the data tables in NOV (NDataTable) check out the Data Tables documentation topic.
By Mike Willis - 6 Years Ago
Thanks!  When deriving from NMailMergeDataSource 
The compiler requires the implementation of Wwr() and Xwr().
When those are implemented the compiler then complains "No suitable method to override"
I don't find the methods Wwr() and Xwr() in the inheritance chain either.
Code below.  Any suggestions?

public class DocumentMergeDataSource:NMailMergeDataSource
  {
   public override NDataTable GetDataTable()
   {
    DocumentDataSet ds = new DocumentDataSet();
    return ds.DocumentToNDataTable();

   }

   internal override string Wwr()
   {
    throw new NotImplementedException();
   }

   internal override string Xwr()
   {
    throw new NotImplementedException();
   }
  }
By Mike Willis - 6 Years Ago
Hey,
Attempting to do as you suggest "by creating a class that inherits NMailMergeDataSource, overriding its GetDataTablecreate a class that inherits from NMailMergeDataSource."
However i get these compiler errors
ErrorCS0115'DocumentMergeDataSource.Xwr()': no suitable method found to override
ErrorCS0115'DocumentMergeDataSource.Wwr()': no suitable method found to override
ErrorCS0534'DocumentMergeDataSource' does not implement inherited abstract member 'NMailMergeDataSource.Xwr()'
ErrorCS0534'DocumentMergeDataSource' does not implement inherited abstract member 'NMailMergeDataSource.Wwr()'

this is the code
"public class MyMailMergeDataSource : NMailMergeDataSource
  {
   public override NDataTable GetDataTable()
   {
    Business.DocumentDataSet ds = new Business.DocumentDataSet();
    return ds.DocumentToNDataTable();

   }

   internal override string Wwr()
   {
    throw new NotImplementedException();
   }

   internal override string Xwr()
   {
    throw new NotImplementedException();
   }
  }"
By Mike Willis - 6 Years Ago
Changed inheritance  to NMemoryMailMergeDataSource
By Mike Willis - 6 Years Ago
After changing the base class to NMemoryMailMergeDataSource, i receive object not set to instance of object error.
Event this simple class gives an error.
public class TestMergeDataSource:NMemoryMailMergeDataSource
  {

  }"
need more assistance!
Mike
By Nevron Support - 6 Years Ago
You can use the NMemoryMailMergeDataSource directly without creating a class that inherits it. Simply create an NMemoryDataTable with the data you want to use for mail merge and pass it to the constructor of NMemoryMailMergeDataSource that accepts a data table:

richTextView.Content.MailMerge.DataSource = new NMemoryMailMergeDataSource(dataTable);

By Mike Willis - 6 Years Ago
Had to add the following to my class
public static readonly NSchema NDatsMailMergeDataSourceSchema;
   static DatsMailMergeDataSource()
   {
    NDatsMailMergeDataSourceSchema = NSchema.Create(typeof(DatsMailMergeDataSource), NMemoryMailMergeDataSource.NMemoryMailMergeDataSourceSchema);
   }