Hi,
I recently realized in almost the end of my creation process that the browser form do not support copy paste functionality from Excel. To set the scene - I am not able to implement Qdabra software,so the only way is to find a existing suitable solution on and was looking for some hints and tips on the web. Unfortunately I am not (yet) that brilliant with proposed solutions:
1. I tried figuring out and understanding the solution proposed by Patrick here:
http://www.infopathdev.com/blogs/patrick/archive/2011/09/03/free-sample-copying-repeating-data.aspx
but I am confused by the fact that the "delete" and "put new 5 rows" buttosn relate to Qdabra secondary data source. I was trying to replicate the approach and building an example file myself, but somehow it did not work. Has somebody tried to implement the approach?
Secondly I tried to find a code solution, and this time it brought a following results:
I am able to copy over the content from secondary data source, number of rows match (have 3 rows in secondary xml file), but in my case only the first one is copied over and in my case 3 times.
I also dont know if besided putting the code behnid the button - should i also put conditional action, which would refresh the connection to secondary data source upon button click?
Plus the code I have used in VBA:
Public Sub CTRL5_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
' Write your code here.
Dim secDSNav As XPathNavigator = DataSources("MyContacts").CreateNavigator()
' Retrieve the rows of the secondary data source
Dim rows As XPathNodeIterator = secDSNav.Select( _
"/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW", _
NamespaceManager)
' Loop through the rows of the secondary data source and fill the repeating table
While rows.MoveNext()
Dim lastname As String = rows.Current.SelectSingleNode( _
"/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Title", NamespaceManager).Value
Dim firstname As String = rows.Current.SelectSingleNode( _
"/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:FirstName", NamespaceManager).Value
Dim email As String = rows.Current.SelectSingleNode( _
"/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Email", NamespaceManager).Value
' Add the item to the repeating table
AddItem(lastname, firstname, email)
End While
DeleteFirstEmptyItem()
End Sub
Private Sub AddItem( _
ByVal lastname As String, ByVal firstname As String, ByVal email As String)
Dim doc As XmlDocument = New XmlDocument()
Dim group As XmlNode = doc.CreateElement("group2", _
NamespaceManager.LookupNamespace("my"))
Dim field As XmlNode = doc.CreateElement("field1", _
NamespaceManager.LookupNamespace("my"))
Dim node As XmlNode = group.AppendChild(field)
node.InnerText = lastname
field = doc.CreateElement("field2", _
NamespaceManager.LookupNamespace("my"))
node = group.AppendChild(field)
node.InnerText = firstname
field = doc.CreateElement("field3", _
NamespaceManager.LookupNamespace("my"))
node = group.AppendChild(field)
node.InnerText = email
doc.AppendChild(group)
MainDataSource.CreateNavigator().SelectSingleNode( _
"/my:myFields/my:group1", _
NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator())
End Sub
Private Sub DeleteFirstEmptyItem()
Dim domNav As XPathNavigator = MainDataSource.CreateNavigator()
Dim itemNav As XPathNavigator = domNav.SelectSingleNode( _
"/my:myFields/my:group1/my:group2[1]", _
NamespaceManager)
If itemNav IsNot Nothing Then
itemNav.DeleteSelf()
End If
End Sub
End Class
End Namespace