Inserting a row by clicking a check box - InfoPath Dev
in

InfoPath Dev

Inserting a row by clicking a check box

Last post 07-17-2010 05:50 AM by Skarn. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-16-2010 08:03 AM

    • MikeJL
    • Not Ranked
    • Joined on 07-16-2010
    • Posts 1

    Inserting a row by clicking a check box

    Hi,

    I am currently using InfoPath 2010 and have created a repeating table with a few text boxes and a single check box.  When i click the check box i want to insert a row after (a function usually executed through the keystrokes: ctrl+enter).  I have already tried the ideas suggested here: http://www.bizsupportonline.net/infopath2007/4-way-programmatically-add-row-repeating-table.htm however, I continue to get an error message saying "schema validation found non-datatype errors."  

    Your help would be appreciated. Thank you.

  • 07-17-2010 05:50 AM In reply to

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

    Re: Inserting a row by clicking a check box

    Example using jScript - Repeating group is called 'rGroup' 
    =========================================

    On the 'After Validate' event of a 'check box' field named 'fCheck' contained in rGroup with a checked value of 1 and unchecked value of -1

    if(eventObj.Source.selectSingleNode(".").text =='1')
    {

    var nodeParent = eventObj.Source.selectSingleNode("../..");
    var nodeNextSibling = eventObj.Source.selectSingleNode("..").nextSibling;

     //Get a reference to the sampledata DOM.
     var objSampleDataDOM = XDocument.DOM;
     
     //Create a new DOMDocument, and load the template into it.
     var objTemplateDoc = XDocument.CreateDOM();
     objTemplateDoc.validateOnParse = false;
     objTemplateDoc.load("template.xml");
     
     //Set the SelectionNamespaces to the same value as the main DOM.
     var strSelectionNamespaces = objSampleDataDOM.getProperty("SelectionNamespaces");
     objTemplateDoc.setProperty("SelectionNamespaces", strSelectionNamespaces );

    //Clone the repeating group from the 'template' DOM
     var nodeClone = objTemplateDoc.selectSingleNode("//my:rGroup").cloneNode(true);

    //Insert the new node (if nodeNextSibling is null then it will append)
     var nodeNew = nodeParent.insertBefore(nodeClone,nodeNextSibling); 

    }

    You probably want to reset the checkbox after the insert occurs?

    Just add eventObj.Source.selectSingleNode(".").text = '-1' to the code.

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