Repeating table headaches - InfoPath Dev
in

InfoPath Dev

Repeating table headaches

Last post 10-12-2012 07:32 AM by Gennady Vanin (Геннадий Ванин, Новосибирск). 21 replies.
Page 1 of 2 (22 items) 1 2 Next >
Sort Posts: Previous Next
  • 10-09-2012 03:34 AM

    • Queenie
    • Not Ranked
      Female
    • Joined on 10-08-2012
    • Nottingham, UK
    • Posts 12

    Repeating table headaches

    Morning all,

     I am fairly new to Infopath but realising it is the least complicated way to do things. I am having an issue at the moment with a repeating table in my form. While your lovely forum has taught me so much already, I can't find anything to help me with this Repeating Table of Doom™

     At present it looks like this:

    Task

    Week 1

    Week 2

    Week 3

    Week 4

    "Stuff"

    5

    4

    3

    2

    People have to fill in this form every week and can add as many tasks as they need to along with how many days they plan on spending on those tasks in the next four weeks. In order to make filling in the form easier from week to week I have also included two control buttons [<] and [>] with the idea that if they were to click [<] next week the data would shift across a week leaving the fourth week blank. I have a standard table elsewhere in the form where this works fine, just using rules ("Set a Field's Value"). The issue I am having is when there are two or more tasks inserted. The table goes from looking like this:

    Task

    Week 1

    Week 2

    Week 3

    Week 4

    "Stuff"

    5

    4

    3

    2

    "More Stuff"

    1

    2

    3

    4

    to:

    Task

    Week 1

    Week 2

    Week 3

    Week 4

    "Stuff"

    4

    3

    2

    0

    "More Stuff"

    4

    3

    2

    0

    as all the rows' data defaults to that of Row 1 upon the click of the button. Is this something that can be fixed? Would I need to use VSTA or xpath to try and get each row to retain data? I have no idea how to proceed from here so any help would be much appreciated.

    Queenie

    Queenie: I may have the body of a weak and feeble woman, but I have the heart and stomach...of a concrete elephant!
    Partridge: Prove it!
    Queenie: Certainly will! [picks up a tankard] First I'm going to have a little drinky...and then I'm going to execute the whole bally lot of you!
  • 10-09-2012 04:27 AM In reply to

    Re: Repeating table headaches

    Queenie:
    People have to fill in this form every week and can add as many tasks as they need to along with how many days they plan on spending on those tasks in the next four weeks. In order to make filling in the form easier from week to week I have also included two control buttons [<] and [>] with the idea that if they were to click [<] next week the data would shift across a week leaving the fourth week blank. I have a standard table elsewhere in the form where this works fine, just using rules ("Set a Field's Value").

    Hi Queenie,

    If I understand the requirement correctly, you essentially want to have the ability to horizontally roll data over a 4 week period? Personally (and being a developer) - I would turn straight to defining this logic in the button click event handlers for [<] amd [>]. In a few of the forms that I have done in the past that have a repeating table (especially those that required the row values to be processed in some way), I have resorted to VSTA and XPath. If you can clarify the requirement and possibly a screenshot of the repeating table and buttons, I might be able to post some code up to assist you.

    As far as I can tell (and I could be mistaken on this), Rules only get access to the first row in a Repeating Table. Using code you will be able to iterate through each of them.

  • 10-09-2012 04:36 AM In reply to

    • Queenie
    • Not Ranked
      Female
    • Joined on 10-08-2012
    • Nottingham, UK
    • Posts 12

    Re: Repeating table headaches

     Thanks for the reponse!

     You are correct in your understanding. I need to horizontally roll data, but actually over an 8 week period without the second/third/etc., task data reverting to that of the first task (I simplified a little for the explanation's purposes). I had a nasty feeling I might have to play with VSTA a little. Unfortunately I am working from home at the moment and the company's servers seem to be down so I can't post a screenshot of the exact table at present. I have only just started learning to use VB6 but I might be able to have a go at sorting the button click event handlers.

    Can you use XPath within VSTA to define fields?

    Queenie: I may have the body of a weak and feeble woman, but I have the heart and stomach...of a concrete elephant!
    Partridge: Prove it!
    Queenie: Certainly will! [picks up a tankard] First I'm going to have a little drinky...and then I'm going to execute the whole bally lot of you!
  • 10-09-2012 06:01 AM In reply to

    Re: Repeating table headaches

    It is actually quite easy to do. To setup the event handler, right click on the button control and go to properties.
    In the general tab, there will be a button with the label, "Edit Form Code".
    Clicking this button will register the event handler and also create the procedure shell.

    The [<] button click event logic would be like so;

    public void CTRL7_5_Clicked(object sender, ClickedEventArgs e)

    {

        XPathNavigator nav = MainDataSource.CreateNavigator();

        XPathNodeIterator NodeIterator = nav.Select("/my:myFields/my:group1/my:group2", NamespaceManager);

        XPathNavigator node;

        while (NodeIterator.MoveNext())

        {

             node = NodeIterator.Current.CreateNavigator();

             node.SelectSingleNode("my:txtWeek1", NamespaceManager).SetValue(node.SelectSingleNode("my:txtWeek2", NamespaceManager).Value);

             node.SelectSingleNode("my:txtWeek2", NamespaceManager).SetValue(node.SelectSingleNode("my:txtWeek3", NamespaceManager).Value);

             node.SelectSingleNode("my:txtWeek3", NamespaceManager).SetValue(node.SelectSingleNode("my:txtWeek4", NamespaceManager).Value);

             node.SelectSingleNode("my:txtWeek4", NamespaceManager).SetValue("0");

        }

    }


    The [>] button click event logic would be like so;

    public void CTRL8_5_Clicked(object sender, ClickedEventArgs e)

    {

        XPathNavigator nav = MainDataSource.CreateNavigator();

        XPathNodeIterator NodeIterator = nav.Select("/my:myFields/my:group1/my:group2", NamespaceManager);

        XPathNavigator node;

        while (NodeIterator.MoveNext())

        {

             node = NodeIterator.Current.CreateNavigator();

             node.SelectSingleNode("my:txtWeek4", NamespaceManager).SetValue(node.SelectSingleNode("my:txtWeek3", NamespaceManager).Value);

             node.SelectSingleNode("my:txtWeek3", NamespaceManager).SetValue(node.SelectSingleNode("my:txtWeek2", NamespaceManager).Value);

             node.SelectSingleNode("my:txtWeek2", NamespaceManager).SetValue(node.SelectSingleNode("my:txtWeek1", NamespaceManager).Value);

             node.SelectSingleNode("my:txtWeek1", NamespaceManager).SetValue("0");

        }

    }

    Just be sure to change the XPath expressions to suit your form controls.

  • 10-09-2012 06:03 AM In reply to

    Re: Repeating table headaches

    Queenie:
    as all the rows' data defaults to that of Row 1 upon the click of the button
     

    Is it the same problem as in yesterday's post  ?

    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
  • 10-09-2012 06:07 AM In reply to

    • Queenie
    • Not Ranked
      Female
    • Joined on 10-08-2012
    • Nottingham, UK
    • Posts 12

    Re: Repeating table headaches

     butsa80 - thanks for the code - I shall try it when the servers are back up and running. It looks fairly straight forward to follow but, like most languages, easier to read than create from scratch. Will let you know how it goes.

    Gennady - Having had a look at the other post I don't think it's the same issue, unless I am understanding the other file completely wrong.

    Queenie: I may have the body of a weak and feeble woman, but I have the heart and stomach...of a concrete elephant!
    Partridge: Prove it!
    Queenie: Certainly will! [picks up a tankard] First I'm going to have a little drinky...and then I'm going to execute the whole bally lot of you!
  • 10-09-2012 06:18 AM In reply to

    • Queenie
    • Not Ranked
      Female
    • Joined on 10-08-2012
    • Nottingham, UK
    • Posts 12

    Re: Repeating table headaches

     Gennady - I also have Infopath 2007 which doesn't seem to let me drag and drop anything anyway. Trying to follow your answer logically in a separate sheet with the same table still gives the same result - each row reverts to that of row 1.

    Queenie: I may have the body of a weak and feeble woman, but I have the heart and stomach...of a concrete elephant!
    Partridge: Prove it!
    Queenie: Certainly will! [picks up a tankard] First I'm going to have a little drinky...and then I'm going to execute the whole bally lot of you!
  • 10-09-2012 07:16 AM In reply to

    • Queenie
    • Not Ranked
      Female
    • Joined on 10-08-2012
    • Nottingham, UK
    • Posts 12

    Re: Repeating table headaches

    Drat - I just remembered Infopath won't be able to mix languages - can you do something similar in VB?

    Queenie: I may have the body of a weak and feeble woman, but I have the heart and stomach...of a concrete elephant!
    Partridge: Prove it!
    Queenie: Certainly will! [picks up a tankard] First I'm going to have a little drinky...and then I'm going to execute the whole bally lot of you!
  • 10-09-2012 07:52 AM In reply to

    Queenie:
    2007 which doesn't seem to let me drag and drop anything anyway
     

    It was unrelated to drag'n'dropping (or right-clicking > choosing contextual options) ...
    it was about difference (amd probable mismatch in understanding the diff) between data fields and controls...

    Anyway, could you just edit multi-item  repeating defaults? In Infopath Designer 2010,  in File > Info > Form Optons > Advanced > Edit Default Values.... ) or, what is the same, on Ribbon Data tav > Default Values (under Form Data)

     I checked that it works in compatibility "Web Browser Form (2007)"

    Editing Repeating Default Values (Gennady Vanin) 

     Fig.1. Editing Repeating Default Values. 

     

     Fig. 2. Previewing default values

     Fig. 2. Previewing default values

     

     

     

     

    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
  • 10-10-2012 03:37 AM In reply to

    • Queenie
    • Not Ranked
      Female
    • Joined on 10-08-2012
    • Nottingham, UK
    • Posts 12

    Re: Repeating table headaches

    Gennady - as far as I can make out, you are suggesting I change my form so that multiple rows are automatically shown when the form is opened, and that the numbers in the boxes are defaulted?

     I feel I'm being particularly obtuse here :(

    Queenie: I may have the body of a weak and feeble woman, but I have the heart and stomach...of a concrete elephant!
    Partridge: Prove it!
    Queenie: Certainly will! [picks up a tankard] First I'm going to have a little drinky...and then I'm going to execute the whole bally lot of you!
  • 10-10-2012 08:16 PM In reply to

    Re: Repeating table headaches

    Yes.

    I was not clear what was your problem and still am not

    You probably should have attached your template with the post from the very beginning

    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
  • 10-11-2012 02:26 AM In reply to

    • Queenie
    • Not Ranked
      Female
    • Joined on 10-08-2012
    • Nottingham, UK
    • Posts 12

     There we go - I fixed up a sample which shows my issue. Hopefully playing with that will show what my problem is.

     Thanks for your patience.

    Queenie: I may have the body of a weak and feeble woman, but I have the heart and stomach...of a concrete elephant!
    Partridge: Prove it!
    Queenie: Certainly will! [picks up a tankard] First I'm going to have a little drinky...and then I'm going to execute the whole bally lot of you!
  • 10-11-2012 06:44 AM In reply to

    Re: Repeating table headaches

     Ooops, I see

    I believe the solution requires using of current() in Rules XPath expressions and it would probably require editing source files, since it is related to bug (impossibility to OOTB edit XPath expression of the target of Rule) and workaround described in:

    Not sure yet and, unfortunately, I do not have time now to look into and reply you with concrete (codeless, IMO you should avoid code) solution but I have asked Hilary to look into your question

    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
  • 10-11-2012 06:49 AM In reply to

    • Queenie
    • Not Ranked
      Female
    • Joined on 10-08-2012
    • Nottingham, UK
    • Posts 12

    Re: Repeating table headaches

     Thanks for checking back :)

    Queenie: I may have the body of a weak and feeble woman, but I have the heart and stomach...of a concrete elephant!
    Partridge: Prove it!
    Queenie: Certainly will! [picks up a tankard] First I'm going to have a little drinky...and then I'm going to execute the whole bally lot of you!
  • 10-11-2012 07:47 AM In reply to

    Oh. This was fun!

    Attaching your sample with some edits - I added a "helper" field in the repeating group to leverage for the rule actions.

    Hilary Stoupa

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