Current Row in repeating table - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Current Row in repeating table

Last post 04-24-2009 11:19 AM by hortonhouse. 31 replies.
Page 2 of 3 (32 items) < Previous 1 2 3 Next >
Sort Posts: Previous Next
  • 11-20-2008 07:23 AM In reply to

    Re: Current Row in repeating table

    Is the control bound to a field in a repeating group, or a field that repeats? Does the control show any errors, or do you have any errors in the Design Checker task pane? I ask because if the control is bound correctly, I wouldn't expect this behavior.....

    Hilary Stoupa

  • 11-20-2008 08:30 AM In reply to

    Re: Current Row in repeating table

     

    No this control is not bound. This is what my requirement is -: I have a repeating table that gets filled from database. There are some duplicate records that show up in repeating table. So I need a functionality where I can select the check boxes of the records that I want to delete and delete all of them in one press of Delete button.

    I need to get prospect id of all the checkboxes selected.

    How can i get the prospectid of the selected checkbox from the repeating table where checkbox is not bound. I can also bind the checkbox to a dummy boolean record from database?

    Any idea how to do this? 

  • 11-20-2008 11:30 AM In reply to

    Re: Current Row in repeating table

    Well, I wonder. In your main data connection, if you walk through the wizard again, you could click the 'Edit SQL' button and add to your select clause to create a dummy boolean.... like  select col1, col2, 'False' as Selected .... then you should have a column called 'Selected' in your data source set to false that you could use for your checkbox in your repeating table. I warn you -- I haven't actually tried this, but why don't you see if works?

    Hilary Stoupa

  • 11-20-2008 11:41 AM In reply to

    Re: Current Row in repeating table

    Thanks for your response.

    I exactly did that and now I have a checkbox in repeating table. I want to go through each and every row in repeating table and see in which rows the checkbox is selected. Once I know the selected check box rows i need to get prospect id of those rows.

    In the lines below I made the navigator object of datasource and then navigator object of data fields. Now when i debug into code then I can see innerxml of dataFields has all the rows of repeating table.

    My question to you is how should i parse the value of each node of every row in datafields object to get the values of element?

    XPathNavigator myfields = DataSources["FProspect"].CreateNavigator();

    XPathNavigator dataFields = myfields.SelectSingleNode("/dfs:myFields/dfs:dataFields", NamespaceManager);

  • 11-20-2008 02:25 PM In reply to

    Re: Current Row in repeating table

    Well, first off, I'd use my XPath in the second navigator to select only the nodes in the dataFields group that have a value of True (if that is what selecting the checkbox sets the field to) in the checkbox node. And I'd make it an XPathNodeIterator, so it has all of the nodes where the filter applies.

    XPathNodeIterator dataFields = myfields.SelectSingleNode("/dfs:myFields/dfs:dataFields[d:checkboxfield = 'True']", NamespaceManager);

    Naturally, you'll want to replace 'd:checkboxfield' with the relative XPath from dfs:dataFields to your check box field, and if you are setting the value to something other than true, To get the values, you can use something like:

    foreach (XPathNavigator selectedNode in dataFields)
    {
       string value = selectedNode.SelectSingleNode("d:field").Value;
    }

    This is just pseudo-code, so I may have a syntax error or two hanging about.

    Hilary Stoupa

  • 11-20-2008 03:16 PM In reply to

    Re: Current Row in repeating table

    Thank you, I got some idea after seeing your code and I was able to make some progress. I did this in my code

    XPathNavigator rootDefaultData = DataSources["FProspect"].CreateNavigator();

    XPathNodeIterator dataFields = rootDefaultData.Select("/dfs:myFields/dfs:dataFields/tns:FProspectResponse/tns:FProspectResult/tns:FetchProspect/tns:FirstName", NamespaceManager);

    foreach (XPathNavigator selectedNode in dataFields)

    {

    string value = selectedNode.InnerXml;

    }

    but i am wondering that why your this code is not working when it should have worked. I implemented your code that is in bold below but it's not working.Can you please tell why? Value of variable value will not change.

    foreach (XPathNavigator selectedNode in dataFields)
    {
       string value = selectedNode.SelectSingleNode("d:field").Value;
    }

     

  • 11-20-2008 03:35 PM In reply to

    Re: Current Row in repeating table

    Well, the code you've highlighted in bold suggests that you would have a data node at:

     /dfs:myFields/dfs:dataFields/tns:FProspectResponse/tns:FProspectResult/tns:FetchProspect/tns:FirstName/d:field

    which seems reasonably unlikely.

    Use XPathNavigator to select a single node, and XPathNodeIterator to select a list of nodes. Unless First Name is a list (which I doubt), you would want to use XPathNavigator. From your earlier code snippet, I thought you wanted to get a list of all the nodes that have been selected with your checkbox in your form. At this point, I'm afraid I'm not feeling like I understand what you are hoping to accomplish.

    What do you need the code in your form to do, exactly?

    Hilary Stoupa

  • 11-20-2008 04:59 PM In reply to

    Re: Current Row in repeating table

    I am so sorry if I have confused you. I have a field prospectid in repeating table which comes from the database along with other fields. I wanted to put the checkbox in repeating table so that uses can select the prospects from the repeating table to delete them. I was able to put the check box by putting boolean dummy field in select statement and binding that checkbox with that dummy boolean field.

     I still have to do the same thing but the code that i showed in last post i used firstname but it was for testing.

     Goal is still the same to select the prospects from the repeating table to delete them. So I have to figure out which checkboxes are selected so that i can pass the prospectid of those selected items to stored procedure for deleting them. Prospectid is one of the fields in repeating table.

     I hope I am not confusing you any more.

     Here is the list of my objects Please let me know how can I accomplish this goal. Thanks

    rootDefaultData = DataSources["FProspect"].CreateNavigator();
    XPathNavigator dataFields = rootDefaultData.SelectSingleNode("/dfs:myFields/dfs:dataFields", NamespaceManager);
    XPathNavigator prosResp = dataFields.SelectSingleNode("/dfs:myFields/dfs:dataFields/tns:FProspectResponse", NamespaceManager);
    XPathNavigator prosResult = dataFields.SelectSingleNode("/dfs:myFields/dfs:dataFields/tns:FProspectResponse/tns:FProspectResult", NamespaceManager); 
    XPathNodeIterator nodeDefaultData = dataFields.Select("/dfs:myFields/dfs:dataFields/tns:FProspectResponse/tns:FProspectResult/tns:FetchProspect/tns:FirstName", NamespaceManager);

  • 11-20-2008 06:21 PM In reply to

    Re: Current Row in repeating table

    I was able to achieve the goal of selecting prospectid for checked boxes. Thank you so much for your great help. Here is my final code that works

    XPathNavigator source = MainDataSource.CreateNavigator();

    XPathNodeIterator row = source.Select("/dfs:myFields/dfs:dataFields/tns:HelloWorldResponse/tns:HelloWorldResult/NewDataSet/Table[mycol='1']", NamespaceManager);

    //XPathNodeIterator row1 = source.Select("/dfs:myFields/dfs:dataFields/tns:HelloWorldResponse/tns:HelloWorldResult/NewDataSet/Table/ProspectFName", NamespaceManager);

     

    foreach (XPathNavigator selectnode in row)

    {

    string value = selectnode.SelectSingleNode("ProspectId").Value;

    }

  • 11-20-2008 10:08 PM In reply to

    Re: Current Row in repeating table

    Hi,

    Follow these steps to select only one radio button in repeating table. 

    Add a rule on the radio button field.
      Set the condition: the expression “. = 1
      Add an action:
       1. For action drop down select set fields value.
       2. Select radio button field by using data source button.
       3. In value text box set 0.


    Save the xsn as source files and open the manifest.xsf in notepad.
     1. Search for the Rule name(e.g Rule 2) that you have given. You will find this node
       <xsf:rule caption="Rule 2" condition=". = 1" isEnabled="yes">
     2. Below this node you will find targetField attribute.
     3. Use the following XPath in that attribute value.
       targetField="../preceding-sibling::my:group4/my:field2|../following-sibling::my:group4/my:field2"

    here group4 is repeating group and field2 is radio button.
     4. Save the manifest.xsf and preview it.

     

  • 11-21-2008 01:03 AM In reply to

    Re: Current Row in repeating table

     

    Hi,

    I think your radio button is binded to the field out of repeating section. Make sure that the radio button field is in the repeating section in the data source. And use the following code in the field on after change.

    [InfoPathEventHandler(MatchPath = "/my:myFields/my:group3/my:group4/my:field7", EventType = InfoPathEventType.OnAfterChange)]

    public void group4_OnAfterChange(DataDOMEvent e)

    {

     if (e.IsUndoRedo || e.Parent.nodeName != "my:field7" || e.Site.text != "1")

     {

                 return;

     }

     

     if (e.Source.text == "1")

     {

       IXMLDOMNode parentNode = e.Source.selectSingleNode("..");

      int currentRowPosition = parentNode.selectNodes("../precedingsibling::my:group4").length + 1;

     IXMLDOMNodeList field7Nodes = thisXDocument.DOM.selectNodes(string.Format("/my:myFields/my:group3/my:group4[position() != {0}]/my:field7[. = '1']", currentRowPosition));

     foreach (IXMLDOMNode field7Node in field7Nodes)

      {     

                 field7Node.text = "0";

       }

     }

    }

     

    Here my:group4 is the repeating field and my:field7 is the radio button field.

    Swathip
    www.ggktech.com
  • 01-13-2009 06:08 AM In reply to

    Re: Current Row in repeating table

    Hi. I have a repeating table with a button in each row. I'd like to get the value of a field in the same row in the OnClick event.

    I went through this post. I am using IP2003 with VBScript. I tried the following:
    count = eventObj.Source.selectNodes("preceding-sibling::Row").length + 1
    msgbox(count)
    Req_Id  = eventObj.Source.selectSingleNode("/dfs:myFields/dfs:dataFields/d:q_inflow_entry[count]/@request_id").value

    But count returns 1 everytime no matter which row I select. And the last line throws an exception 'Object required'. Please help.

  • 01-13-2009 06:28 AM In reply to

    Re: Current Row in repeating table

    Your first line is counting the number of nodes named "Row" preceding eventObj.source, but from the third line, it looks like the repeating node is called "d:q_inflow_entry", not "Row".  That's probably why count is always 1.

    In the third line, you have the literal characters c-o-u-n-t in your XPath string instead of concatenating the value of the count variable into the string.

    But you should not need that roundabout approach to get the value of the node you want.  If d:q_inflow_entry is in fact the repeating node, then

    Req_Id = eventObj.Source.selectSingleNode("@request_id").value

    Should do the trick.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-13-2009 06:49 AM In reply to

    Re: Current Row in repeating table

    Hi Jimmy, Thanks for a quick reply. You saved me. Again!!! I made the changes you suggested and it's working. Thanks.

  • 03-22-2009 10:08 PM In reply to

    • Fawzy
    • Not Ranked
    • Joined on 03-23-2009
    • Posts 1

    Re: Current Row in repeating table

     

     Hi Santhoshp,

     I tried your approach below to select only one radio button in a repeating table but it didn't work, now I'm not able to select any radio button!

    am I missing something?

    Thanks

     

    Hi,

    Follow these steps to select only one radio button in repeating table. 

    Add a rule on the radio button field.
      Set the condition: the expression “. = 1
      Add an action:
       1. For action drop down select set fields value.
       2. Select radio button field by using data source button.
       3. In value text box set 0.


    Save the xsn as source files and open the manifest.xsf in notepad.
     1. Search for the Rule name(e.g Rule 2) that you have given. You will find this node
       <xsf:rule caption="Rule 2" condition=". = 1" isEnabled="yes">
     2. Below this node you will find targetField attribute.
     3. Use the following XPath in that attribute value.
       targetField="../preceding-sibling::my:group4/my:field2|../following-sibling::my:group4/my:field2"

    here group4 is repeating group and field2 is radio button.
     4. Save the manifest.xsf and preview it.

     

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