Insert Blank Rows to Repeating Table - InfoPath Dev
in

InfoPath Dev

Insert Blank Rows to Repeating Table

Last post 02-11-2015 11:01 AM by JonesAF. 18 replies.
Page 2 of 2 (19 items) < Previous 1 2
Sort Posts: Previous Next
  • 07-02-2009 10:38 AM In reply to

    Re: Insert Blank Rows to Repeating Table

    RIght, but as discussed earlier in this thread, you can't use the 2003 object model in browser compatible forms....

    Hilary Stoupa

  • 01-24-2012 06:24 AM In reply to

    Re: Insert Blank Rows to Repeating Table

    Hilary,

    I can really use this solution but I am struggling trying to get it to work. I am not sure if it is the structure of my XML file or something else. I run this on button clik

     

     XPathNavigator parent = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:CommoditySummary/my:Line_Items", NamespaceManager);
                        
      //get our repeating group from sampledata.xml
      XmlDocument sample = new XmlDocument();
      sample.Load(this.Template.OpenFileFromPackage("CmdtyRow.xml"));

      XPathNavigator newGroup = sample.CreateNavigator().SelectSingleNode("/my:myFields/my:CommoditySummary/my:Line_Items/my:Commodity", NamespaceManager);
     
      parent.AppendChild(newGroup) XPathNavigator parent = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:CommoditySummary/my:Line_Items", NamespaceManager);
                        
      //get our repeating group from sampledata.xml
      XmlDocument sample = new XmlDocument();
     sample.Load(this.Template.OpenFileFromPackage("CmdtyRow.xml"));

     XPathNavigator newGroup = sample.CreateNavigator().SelectSingleNode("/my:myFields/my:CommoditySummary/my:Line_Items/my:Commodity", NamespaceManager);
     
      parent.AppendChild(newGroup); // here I get an error value cannot be null Parameter name: newChild

     

    Any suggestions?

    Kind regards,
    Larry
  • 09-30-2012 11:11 PM In reply to

    Re: Insert Blank Rows to Repeating Table

    Not sure if this topic is closed, or whether it should resurrect with each new InfoPath version :-(

    How would I insert a new row in InfoPath 2010?

    Ideally I intend using a Repeating Table for record the Review Dates when a list item is viewed (or reviewed with comments)

    The RT will initially be empty and the first row will have the access date added when the form is closed. Next time the form is opened the RT needs to have a row added to enable the new access date to be inserted.

    Any thoughts would be greatly appreciated

    leslie

  • 02-11-2015 11:01 AM In reply to

    Re: Insert Blank Rows to Repeating Table

    Hi Hilary, I have a similar situation. I think what you have shared here has gotten me part of the way. Here is what I have done so far: What I am trying to do is simple, but I cannot figure it out. I am ready to just give up so please help. 1. How do I create and XML structure that I can then read back into InfoPath to automatically insert the values from my XML into my repeating table? 2. I would like to use a drop-down list to select / set the XMLml file it should be reading in. thanks for any help Here is my current XML structure based the one you shared here: sampledata.xml
    My current c#(2007) code
    "using Microsoft.Office.InfoPath; using System; using System.Windows; using System.Xml; using System.Xml.XPath; namespace CustomRepeatingSection { public partial class FormCode { // Member variables are not supported in browser-enabled forms. // Instead, write and read these values from the FormState // dictionary using code such as the following: // // private object _memberVariable // { // get // { // return FormState["_memberVariable"]; // } // set // { // FormState["_memberVariable"] = value; // } // } // NOTE: The following procedure is required by Microsoft InfoPath. // It can be modified using Microsoft InfoPath. public void InternalStartup() { EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading); } public void FormEvents_Loading(object sender, LoadingEventArgs e) { //get your repeating group. The XPath in quotes needs to change according to your form's data structure //you want to add a new row only if there is no completely blank row available, so we will filter our XPath to only select a group where all the fields are blank //my group only has two fields. Yours may be different. You'll need to change the bit in the square brackets to address your data structure XPathNavigator parent = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:topGroup", NamespaceManager); XPathNavigator group = parent.SelectSingleNode("my:repeatingGroup[my:rgField1 = '' and my:rgField2 = '' and my:rgField3 = '' and my:rgField4 = '']", NamespaceManager); //MessageBox.Show("this method was executed at runtime"); //if our variable group is null, we have no 'empty' rows in our form and need to add one if (null == group) { //get our repeating group from sampledata.xml XmlDocument sample = new XmlDocument(); //sample.Load(this.Template.OpenFileFromPackage("https://team.duke-energy.com/sites/PMCoEP/PMCoE%20Qualification%20Card/QCAssetLib/sampledata.xml")); //sampledata.xml sample.Load("sampledata.xml"); XPathNavigator newGroup = sample.CreateNavigator().SelectSingleNode("/my:myFields/my:topGroup/my:repeatingGroup", NamespaceManager); parent.AppendChild(newGroup); } } } }
    Filed under:
Page 2 of 2 (19 items) < Previous 1 2
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.