Delete Empty Row in a Repeating Table - InfoPath Dev
in

InfoPath Dev

Delete Empty Row in a Repeating Table

Last post 04-19-2013 02:09 PM by Jean-Francois. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 04-19-2007 12:42 PM

    • Tome
    • Not Ranked
      Male
    • Joined on 01-18-2007
    • USA
    • Posts 16

    Delete Empty Row in a Repeating Table

    What I am attempting to do is write jscript to determine if there is a blank row in one of my repeating tables. I removed the ability for users to delete rows but I need to remove blank ones just before I submit to sharepoint and the database. Any hints in regards to how I could do this, would be great.

     


    George Ball
    VeoliaES
    [email protected]
  • 04-20-2007 07:50 AM In reply to

    • ahardin
    • Top 200 Contributor
    • Joined on 02-13-2006
    • United Kingdom
    • Posts 55

    Re: Delete Empty Row in a Repeating Table

    Hi

     Welcome to the forums.

    First off this would have to be done in code run before the submit but it is altogether easier to allow users to delete lines and use valuidation to prevent submission until the line is deleted.

    You could also have a rule that sets another field called CHECK on the end of your row that is invisible to the user that says if the frist row and first column is not blank then set the CHECK field to OK, then use conditional formatting to prevent users from adding to or deleting the control unless all instances of CHECK are not equal to OK.

    I hope this helps

    Adam

    I'm from WALES
    [email protected]
  • 04-21-2007 10:39 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Delete Empty Row in a Repeating Table

    Hi,

    You need to remove the empry rows before submitting the sharepoint or database then you need to write the following code to remove those empty rows.

    //This statement gives the whichever you have all empty rows in repeating section.  

    IXMLDOMSelection emptyRows = (IXMLDOMSelection)thisXDocument.DOM.selectNodes("..\..\my:RepeatingSectionNodeName[my:field1 = '' and my:field2 = '']");

    //This statement removes the all rows which are empty ones 

    emptyRows.removeAll();

     

  • 04-24-2007 04:41 PM In reply to

    • Tome
    • Not Ranked
      Male
    • Joined on 01-18-2007
    • USA
    • Posts 16

    Re: Delete Empty Row in a Repeating Table

    Great..

    var objXMLNode;

    objXMLNode = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:Service_Receipts/d:SR_Employees");

    objXMLNode.removeAll();

    Thanks for the code. I've started adapting it to my form. I can delete all records in the Employees section using the code above. But when I modify the selectNodes line to select records with no employees (code below) nothing happens. Not sure what exactly im doing wrong with it.

    objXMLNode = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:Service_Receipts/d:SR_Employees[empID = '']");


    George Ball
    VeoliaES
    [email protected]
  • 04-25-2007 12:17 AM In reply to

    Re: Delete Empty Row in a Repeating Table

    Hi

    i think prefix is missing for an 'empID'. If the 'EmpID is an element then you should add 'd:' ,if it is an attribute then you should add ' @ ' .

    if empID is an element then the code should be 

    objXMLNode = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:Service_Receipts/d:SR_Employees[d:empID = '']");

    if the empID is an attribute then the code should be

    objXMLNode = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:Service_Receipts/d:SR_Employees[@empID = '']");

    Madhuri
    http://www.ggktech.com
  • 04-25-2007 12:03 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Delete Empty Row in a Repeating Table

    Hi Tome,

    You are using // to starting of your XPath may be that is one thing it goes to wrong. You can use only / to the starting of your XPath. You need to verify if d prefix is required or not for 'Service_Receipts' and 'SR_Employees' node. Check once again your XPath.

  • 04-25-2007 02:52 PM In reply to

    • Tome
    • Not Ranked
      Male
    • Joined on 01-18-2007
    • USA
    • Posts 16

    Re: Delete Empty Row in a Repeating Table

    Done!!

    Thanks for all the help guys. I thought I had tried it already, but the code below worked like a champ.

    var objXMLNode;

    objXMLNode = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:Service_Receipts/d:SR_Employees[@empID = '']");

    objXMLNode.removeAll(); 


    George Ball
    VeoliaES
    [email protected]
  • 04-19-2013 02:09 PM In reply to

    Re: Delete Empty Row in a Repeating Table

    I've tried to use the code above but am still getting many errrors.   Can you help through this?     I want this as a validating code to essentially delete any records where my repeating table brandcode and brandalloc fields are empty.

     

    Public Sub tblbrandalloc_Validating(ByVal sender As Object, ByVal e As XmlValidatingEventArgs)

    ' Write your code here.

     

    var objXMLNode;

    objXMLNode = XDocument.DOM.selectNodes(
    "//dfs:myFields/dfs:dataFields/d:tblfrmid/d:tblCouponMaster/d:tblbrandalloc[d:brandcode="" and d:brandalloc=""]");

    objXMLNode.removeAll();

    End Sub

     

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