Hide rows conditionally

Hi,


Is there a way to hide rows in a ExecuteWithRegions? I have a table within the region and depending on certain conditions in each iteration I want to hide certain rows.

I’ve tried table.Rows[1].Cells.Clear(); but in the next iteration when I need the cells populated again they are still empty.

Maybe I can collapse the row(s) somehow?

Many thanks

Hi Nicola,


Thanks
for your inquiry. There is no direct way that you can hide
entire table row, instead you can use Row.Remove method to achieve this.
I think, you can implement the following workflow to achieve this:

  1. Implament IFieldMergingCallback Interface.
  2. In
    the FieldMergingCallback event, insert a hidden Bookmark at a suitable
    place inside the Row(s) using DocumentBuilder. We just need to flag the
    Row(s) in Table that you want to remove.
  3. Now come to the statement right after ExecuteWithRegions method in the Main method.
  4. Move the cursor to the hidden Bookmark (i.e. inserted in Row(s) during MailMerge) using DocumentBuilder.
  5. Get the Row using GetAncestor method like: Row row = (Row)builder.CurrentNode.GetAncestor(NodeType.Row);
  6. Remove these rows.

Hope this helps you. Please let me know if I can be of any further assistance.