How to get row number (index) in repeating table from a button click inside the table - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

How to get row number (index) in repeating table from a button click inside the table

Last post 08-16-2007 11:27 AM by stpowell. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 08-12-2007 10:02 AM

    How to get row number (index) in repeating table from a button click inside the table

    I am using InfoPath 2007 and writing code in VB.

    I have a repeating table and in the last column I have a button.  When I click on the button I want to determine the row number (index) among other things.

    I have already figured out how to read the date in the row that I click the button.

    e.Source.SelectSingleNode("my:field1", NamespaceManager()).Value

     

    I have tried

    e.Source.Select("XXX").CurrentPosition

    However I can’t figure out what to put in for the xpath string (Note: the XXX is just a placeholder for my question)

     

    I created a test case inored to try determin the the correct code to use.  The data structor is

    myFields

         group1

              group2    <- this is the repeating table

                 field1

     

    My table looks like

     

    ---------------------------

    |  text field  |  button  |  <- Clicking this button should return row 1

    ---------------------------

    |  text field  |  button  |  <- Clicking this button should return row 2

    ---------------------------

    |  text field  !  button  |  <- Clicking this button should return row 3

    ---------------------------

     

    Thank you for your help

    Steve

  • 08-12-2007 10:57 PM In reply to

    Re: How to get row number (index) in repeating table from a button click inside the table

    i guess that myFields/group1/group2[position()]/field1 will give you the value you need. not completely sure, just play around a bit with the position and/or the last() function and the xPath. take care of the bracktes could be () in VB instead of []. hope this helps
    Listen to Motörhead cos they play Rock'n Roll :)
  • 08-13-2007 07:31 AM In reply to

    Re: How to get row number (index) in repeating table from a button click inside the table

    Position()  is not recognized as a valid function in InfoPath 2007 using VB.  In VB you do use brackets.

    I am beginning to wonder if

    e.Source.Select("XXX").CurrentPosition

    is correct.  No mater what I put in for the XXX the CurrentPosition always returns a value of zero.

     

    Are there any other ideas from all the experts?

  • 08-13-2007 07:43 AM In reply to

    Re: How to get row number (index) in repeating table from a button click inside the table

    I have found another post that shows

    var nCount = eventObj.Source.selectNodes("preceding-sibling::Row").length + 1;

     

    and it states that this should give me the current row.  However I believe this code is for C#.  Assuming that it works in C#, is there a VB syntax of this code?

  • 08-13-2007 10:33 PM In reply to

    Re: How to get row number (index) in repeating table from a button click inside the table

    it's not c# it's jscript. try to replace var with set
    Listen to Motörhead cos they play Rock'n Roll :)
  • 08-14-2007 09:30 AM In reply to

    Re: How to get row number (index) in repeating table from a button click inside the table

    Hi  I was wanting to do something similar.  I created an additional hidden field in my group - with a default value of

    count(preceding-sibling::Group2) + 1

    then when the button is clicked the value in the hidden field can be used.

    Just an idea

    Catharine

  • 08-14-2007 07:37 PM In reply to

    Re: How to get row number (index) in repeating table from a button click inside the table

    I tried putting in count(preceding-sibling::Group2) + 1 as the value and when I clicked the verified the formula button, I received the following error:

    "preceding-sibling::Group2" does not point to a valid location path of a field or group.

     

    I then tried count(“preceding-sibling::Group2”) + 1 and got the following error message:

    Argument 1 must return a node-set.

    -->count("preceding-sibling::Group2")<-- + 1

     

    Anyone have any other ideas?

     

    Steve

  • 08-16-2007 03:18 AM In reply to

    Re: How to get row number (index) in repeating table from a button click inside the table

    just to be sure is Group2 really the name of your repeating section or do you use the correct name in your solution and just didn't post it here because in my opinoin your statement seems to be correct.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 08-16-2007 11:27 AM In reply to

    Re: How to get row number (index) in repeating table from a button click inside the table

    Yes Group2 is the name of the repeating table (see my orginal post for the data structure).  Could the prblem be that I am coding in VB and not jscript?  I was told thatcount(preceding-sibling::Group2) + 1is jscript.  Maybe you can’t mix jscript in the button rules when using VB code 

    Any other ideas?

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