Wednesday 26 September 2007

Infopath Development Tips 1 - Infopath repeating table manipulation

Infopath forms are the essential part of sharepoint workflow development. Repeating table is also very tempting because it can solve many UI problems when presenting group of data. So the problem is , how do we populate repeating table from the data we have. It's easy. AppendChild method of DOM using managed code and Infopath's powerful conditional formatting.
1. First thing first, let's specify the conditional formatting for repeating table. right click the table, then properties->conditional formatting-> add. Then you can specify when the value of element of table, say , text box is blank, tick "hide this control". This will make sure your table doesn't show extra blank row when inserting the rows. We will see why we might need to hide this row later on.

2. Secondly, we need to use a little code behind to populate the table we have in the IP form. Say the name of the table we have is called docList and the collection of data we have is docArray. so the code will be



//repeating table

relDocListTable = mainRoot.SelectSingleNode("/my:myFields/my:docList", this.NamespaceManager);


//repeating table row
relDocListRow = mainRoot.SelectSingleNode("/my:myFields/my:docList/my:docItem", this.NamespaceManager);

for (int index = 0; index < newrow =" relDocListRow.Clone();" innerxml =" docNameArr[index];">

No comments: