Document Solutions for Word
Report Templates / Template Configuration / Formatters / Block Behavior Formatters
In This Topic
    Block Behavior Formatters
    In This Topic
    Block behavior formatters allow you to modify the default behavior when rendering a data range (a collection of data items). DsWord provides two block behavior formatters:

    Paragraph block behavior (paragraph-block-behavior, pbb) formatter

    Paragraph block behavior formatter is helpful in rendering a range of data or list of items, as a block inside a single table cell. It renders the range of data or items as a vertical list in the single cell of a table. This formatter is applicable only in the case of table cells. The following table demonstrates the difference in generated output without the pbb and with it:

    Without pbb With pbb
    Template Tags {{#ds.seas}}{{ds.seas.name}}{{/ds.seas}} {{#ds.seas}:pbb()}{{ds.seas.name}}{{/ds.seas}}
    Output

    C#
    Copy Code
    // Add a list for oceans, and a nested table for seas:
    doc.Body.Paragraphs.Add("{{#ds}}{{ds.name}}", doc.Styles[BuiltInStyleId.ListParagraph]);
    
    var table = doc.Body.Tables.Add(1, 1);
    table.Style = doc.Styles[BuiltInStyleId.GridTable1LightAccent1];
    var cell_11 = table[0, 0];
    
    //reuse first paragraph of the cell and define seas range with pbb() formatter.
    //This formatter force range to be expanded in single cell, instead of generating row per each item.
    cell_11.GetRange().Paragraphs.First.GetRange().Runs.Add("{{#ds.seas}:pbb()}{{ds.seas.name}}{{/ds.seas}}");
    
    //close parent range #ds.
    doc.Body.Paragraphs.Add("{{/ds}}");

     Limitations

    Run block behavior (run-block-behavior, rbb) formatter

    Run block behavior formatter causes the range blocks (data items in a range) to repeat as runs inside the same paragraph rather than separate paragraphs. The following table demonstrates the difference in generated output without the rbb and with it:

    Without rbb With rbb
    Template Tags {{#ds.seas}}{{ds.seas.name}} ; {{/ds.seas}} {{#ds.seas}:rbb()}{{ds.seas.name}} ; {{/ds.seas}}
    Output

    C#
    Copy Code
    // Add a list for oceans, and a nested table for seas:
    doc.Body.Paragraphs.Add("{{#ds}}{{ds.name}}", doc.Styles[BuiltInStyleId.ListParagraph]);
    
    //Add new paragraph to define seas range with rbb() formatter.
    //This formatter force range to be expanded in single paragraph, instead of generating new paragraph
    //per each item.
    doc.Body.Paragraphs.Add("{{#ds.seas}:rbb()}{{ds.seas.name}} ; {{/ds.seas}}");
    
    //close parent range #ds.
    doc.Body.Paragraphs.Add("{{/ds}}");

    Limitations