programmatically populating drop down list with data from array - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

programmatically populating drop down list with data from array

Last post 02-12-2012 04:10 AM by Skarn. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 02-06-2012 02:37 PM

    programmatically populating drop down list with data from array

    Hi guys, I'm running into an issue trying to programmatically populate a drop down list with data from an array. The reason I need to do this programmatically is because the original datasource brings back approximately 7000 rows of data - needless to say this slows down my infopath form greatly. My solution is to have the user type the search word in a text box, and when they click query, it will only pull the matching records from the database. I have everything working up to this point. I can type in a search word, and have all results that are found to be inserted into an array. My problem now is trying to display the search results into my drop down list. This should be very simple in theory, but i'm running into a wall trying to work around this in Infopath. I guess my question has two parts - understand navigating these xml elements when it comes to drop down lists - and the proper syntax to execute it. I have a repeating group called Vendor ("/my:myFields/my:Vendor") with a field called ddlVendorName ("/my:myFields/my:Vendor/my:ddlVendorName") in this group. I appreciate any input or advice! thanks,
  • 02-07-2012 03:22 PM In reply to

    Re: programmatically populating drop down list with data from array

    I've made some progress, but it's still not working the way it should. I have it working so it now can show the last item of the array in the drop down list. Here is my code so far:

    Dim group1 As XPathNavigator = nav.SelectSingleNode("/my:myFields/my:Vendor", NamespaceManager)
    Dim field As XPathNavigator = nav.SelectSingleNode("/my:myFields/my:Vendor/my:ddlVendorName", NamespaceManager)
    Dim newNode As XPathNavigator
    For i As Integer = 0 To (count - 1)
    newNode = group1.Clone()
    newNode.SelectSingleNode("/my:myFields/my:Vendor/my:ddlVendorName", NamespaceManager).SetValue(arrayList(i))
    group1.InsertAfter(newNode)
    newNode = Nothing
    Next

    It's still not populating all the array data. Any suggestions that I may be overlooking? thanks
  • 02-08-2012 10:39 AM In reply to

    Re: programmatically populating drop down list with data from array

    funny how you resolve your own problems after you post on a forum for help. I finally figured it out. I'll post my solution for other people should they run into my same problem:

    'To populate a dropdown list in Infopath, you need to create a repeating group field which I named "Vendor" and a dropdownlist field under that which I named "ddlVendorName1".
    'Set xpnRootNode to myFields (the root group), set xpnDataGroup to the repeating group created above. Run through the array and display the contents into the
    'list box by cloning xpnTemplate, setting the value of ddlVendorName, and use the InsertAfter method.
    'deleteself after the loop to remove duplicate listings

    Dim xpnRootNode As XPathNavigator = nav.SelectSingleNode("/my:myFields", NamespaceManager)
    Dim xpnDataGroup As XPathNavigator = nav.SelectSingleNode("//my:myFields/my:Vendor", NamespaceManager)
    Dim xpnTemplate As XPathNavigator = xpnDataGroup.Clone()
    For i As Integer = 0 To (count - 1) 'This loops through my array with data to display. my array name is called arrayList
    Dim xpnNewData As XPathNavigator = xpnTemplate.Clone()
    xpnNewData.SelectSingleNode("/my:myFields/my:Vendor/my:ddlVendorName1", NamespaceManager).SetValue(arrayList(i))
    xpnDataGroup.InsertAfter(xpnNewData)
    Next
    xpnDataGroup.DeleteSelf()
  • 02-12-2012 04:10 AM In reply to

    • Skarn
    • Top 50 Contributor
      Male
    • Joined on 04-20-2008
    • Australia
    • Posts 198

    Re: programmatically populating drop down list with data from array

     ok, cool :-) But...could you have just put a filter on the droplist which only selects the values which contain the text of the filter field?

    Like what I've attached.

Page 1 of 1 (4 items)
Copyright © 2003-2018 Qdabra Software. All rights reserved.
View our Terms of Use.