Add Line to repeating table - InfoPath Dev
in

InfoPath Dev

Add Line to repeating table

Last post 02-08-2006 05:36 AM by Andrei. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-07-2006 09:28 AM

    • Andrei
    • Not Ranked
    • Joined on 02-07-2006
    • Canada
    • Posts 3

    Add Line to repeating table

    Hi,
    I created a form with two views (View1 and View2).
    View1 includes the several fields and repeating table. Users fill out the view1 and submit data to database with using web service.
    View2 is using for reading information from database (web service) and present it for user. Plus, if I want to update information in a record that presented by view2 I use a button with a code. Code copy information from the fields in View2 to fields in View1.

    The problem is with adding new line to repeating table in view1 from view2.
    The error:
    "The following call in the form's code failed:View.ExecuteAction Unspecified error.

    This is a piece of my code:

    XDocument.View.SwitchView("View1);
    XDocument.View.ExecuteAction("xCollection::insert", "Item_8");

    If I add a button to View1 with the same code I can add a line to repeating table.

    Dose anybody know how to overcome this problem?

    Thank you,
    Andrei
  • 02-07-2006 09:39 AM In reply to

    Re: Add Line to repeating table

    Hi Andrei and welcome to our forum!

    A similiar action is accomplished in this tutorial:http://infopathdev.com/howto/tutorials/default.aspx?i=80c11a66b08a4572bc2b17f391319a0f

    (Just skip down to the code and look at the appendChild() function)

    Here's an excerpt:

    var oRows = XDocument.DOM.selectNodes("/my:myFields/my:Document/my:Page/my:Table/my:Row");

    // Save a sample node from this list for later - we will have to clone
    // it to add our rows back in.
    var oSampleRow = oRows.nextNode();

    //..........

    // Create a new row by cloning our sample row.
    // This node must be cloned using "deep" mode to maintain structure of the
    // DOM below it. However, we are about to overwrite all of the nodes anyway.
    var oNewRow = oSampleRow.cloneNode(true);

    // Set the values in the new row from the source row
    // that we are reading from on this iteration.
    oNewRow.selectSingleNode("my:Year").text = oSrc.selectSingleNode("@year").nodeValue;
    oNewRow.selectSingleNode("my:Make").text = oSrc.selectSingleNode("@make").nodeValue;
    oNewRow.selectSingleNode("my:Model").text = oSrc.selectSingleNode("@model").nodeValue;
    oNewRow.selectSingleNode("my:Description").text = oSrc.selectSingleNode("@description").nodeValue;

    // Add the row to the table that is on the current page.
    XDocument.DOM.selectSingleNode("/my:myFields/my:Document/my:Page[" + iCurrentPageIndex + "]/my:Table").appendChild(oNewRow);


    All that to say, try looking at appendChild() instead of xCollection functions. I've never worked with xCollection, but I know that appendChild() has never failed me!

    I hope this information helps you out, please let us know how it goes!

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 02-07-2006 11:44 AM In reply to

    • Andrei
    • Not Ranked
    • Joined on 02-07-2006
    • Canada
    • Posts 3

    Re: Add Line to repeating table

    Hi Matt,

    It is working! Thank you. But I faced another problem now.

    My repeat table has a drop-down field with a couple rules that update two fields in the same line of the table. That rules are not fired now when I use appendChild().

    Are the any way to run rules after adding lines?

    Thank you,
    Andrei
  • 02-07-2006 12:49 PM In reply to

    Re: Add Line to repeating table

    You could try two things.

    "Touch" the drop-down list to fire the rules:

    var original = dropdown.text;
    dropdown.text = "";
    dropdown.text = original;

    Or, implement the rules in code and run them whenever you insert a new row. I've never personally implemented the first option, but I think it would be better because then you would only have to maintain rules functionality in one place instead of in the rules dialog and in the code.

    I hope this helps!

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 02-08-2006 05:36 AM In reply to

    • Andrei
    • Not Ranked
    • Joined on 02-07-2006
    • Canada
    • Posts 3

    Re: Add Line to repeating table

    I used "Touch" approach and the table was updated.

    Thank you for advises.

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