in

InfoPath Dev

Repeating Table

Last post 06-25-2007 09:32 AM by Greg Collins. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 04-24-2007 12:13 PM

    Repeating Table

    I have a drop-down control where the user selects a location.  I need to populate a repeating table based on their selection.

    So, I pick Kanas City and then the repeating table gives me Name, Email, Phone of each person in Kansas City.  All of my datasources are in Sharepoint lists.

    I tried the Binding options of the repeating table but it doesn't allow for filtering based on another field, that I could find.

  • 04-24-2007 12:32 PM In reply to

    Re: Repeating Table

    Unfortunately filtering isn't available on secondary data sources. However, you can use conditional formatting which can accomplish the same thing.

    Visit my Web site:

    http://www.braintrove.com

    Greg Collins / Microsoft MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 04-24-2007 12:50 PM In reply to

    Re: Repeating Table

    I've just discovered that if I bind it to a secondary data source then a user can't insert new items. 

     The most desirable solution is to set the repeating table values through a rule or code using the secondary datasource.  Is this possible?

  • 04-24-2007 02:23 PM In reply to

    Re: Repeating Table

    While you can set values with rules, the most useful method is using code. This will allow you to properly pinpoint the correct row and fields.

    Using code you can also get by the limitation about adding/removing rows in a 2DS repeating table. In code you can simply insert a new row node, or remove one. Set up buttons that call into the code to accomplish this (i.e. an "Insert New Row" button, etc).

    Visit my Web site:

    http://www.braintrove.com

    Greg Collins / Microsoft MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 04-25-2007 06:51 AM In reply to

    Re: Repeating Table

    I've not been able to find any examples on reading a secondary data source and writing the data to a repeating table.  Can you point me in the correct direction?

    Also, what is 2DS limitation?

  • 04-25-2007 10:35 AM In reply to

    Re: Repeating Table

    2DS is my abbreviation for Secondary Data Source. Repeating tables bound to a 2DS are basically 2nd class citizens in InfoPath (unfortunately)--there are a lot of features turned off for them (as you've seen, inserting rows, filtering, etc).

    Modifying the DOM of a 2DS is the same as working with your main DOM. If you are using the InfoPath 2003 object model, you'd be using thing like selectSingleNode() and appendChild() to add a new row. If you are using the InfoPath 2007 object model, then you'd be using the XmlNode, etc objects to do the same thing. Sorry I don't have any links to point you to... but it is basic XML DOM manipulation, and there should be plenty of sources that explain how to do this.

    Visit my Web site:

    http://www.braintrove.com

    Greg Collins / Microsoft MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 06-21-2007 02:54 PM In reply to

    Re: Repeating Table

    This is what worked for me.  Notice the switch statment to prevent event bubbling.

    function msoxd_my_Location::OnAfterChange(eventObj)
    {
     if (eventObj.IsUndoRedo)
     {
      return;
     }

     switch(eventObj.Operation)
     {
      case "Delete":
       restoreRepeatingTable("group2_297");
       break;
      case "Insert":
       if (eventObj.NewValue != "")
       {
        fillPlantNotificationList();
       }
       break;
      default:
       break; 
     }
    }

    function restoreRepeatingTable(cXmlToEdit)
    {
     XDocument.View.ExecuteAction("xCollection::removeAll", cXmlToEdit);
     XDocument.View.ExecuteAction("xCollection::insert", cXmlToEdit);
    }

    function fillPlantNotificationList()
    {
     var oPnlItem = me.selectSingleNode("//my:PnlItem");
     var oPnl  = me.selectSingleNode("//my:PlantNotificationList");
     var cLocation = me.selectSingleNode("//my:Location").text;

     var oContacts = XDocument.DataObjects("Workflow").DOM.selectNodes("//dfs:Workflow[@Location='" + cLocation + "']");
     
     if (oContacts)
     {
      for (var i = 0; i < oContacts.length; i++)
      {
       var oNewItem = oPnlItem.cloneNode(true);
       oNewItem.selectSingleNode("my:PnlName").text = oContacts.item(i).selectSingleNode("@First_Name").text + " " + oContacts.item(i).selectSingleNode("@Last_Name").text + "";
       oNewItem.selectSingleNode("my:PnlEmail").text = (address = oContacts.item(i).selectSingleNode("@E-mail_Address"))? address.text: "";
       oNewItem.selectSingleNode("my:PnlPhone").text = (phone = oContacts.item(i).selectSingleNode("@Business_Phone"))? phone.text: "";
       oPnl.insertBefore(oNewItem, oPnlItem); 
      }
     }
    }

     

  • 06-25-2007 09:32 AM In reply to

    Re: Repeating Table

    Glad you got it working! Thanks for sharing this.
    Visit my Web site:

    http://www.braintrove.com

    Greg Collins / Microsoft MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (8 items)
Copyright © 2003-2007 Qdabra Software. All rights reserved.
View our Terms of Use.