Filtering repeating table with secondary datasourc - InfoPath Dev
in

InfoPath Dev

Filtering repeating table with secondary datasourc

Last post 03-28-2007 04:44 PM by Greg Collins. 14 replies.
Page 1 of 1 (15 items)
Sort Posts: Previous Next
  • 03-08-2007 09:21 AM

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Filtering repeating table with secondary datasourc

    It is evident that when a repeating table is bound to a secondary data-source if is not possible to use filters under the settings for the control. Can anyone give advice on how to do this in the XSL view file?

    Many Thanks for any assistance.
  • 03-08-2007 09:44 AM In reply to

    Re: Filtering repeating table with secondary datasourc

    You can use conditional formatting to accomplish the same thing, though they are not as efficient as filters.

    However, if you are familiar with XPath, you should be able to easily add a filter to your repeating table. Find the xsl:for-each row, and add your filter to the XPath...

    <xsl:for-each select="OriginalXPath[MyFilter]">...</xsl:for-each>
  • 03-08-2007 03:11 PM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Filtering repeating table with secondary datasourc

    Many thanks for that Greg.

    I have a simple filter working and I am now trying a more complex
    filter but this is giving me an error message of:

    "Required white space was missing.".

    I have two textbox fields field1 and field2. I wish to filter using
    these if they are not blank against two fields of the secondary datasource.

    The filter I have is as follows:

    xdXDocument:GetDOM("Secondary Datasource")/Group1/Group2[contains(Code, xdXDocument:get-DOM()/my:myFields/my:field1[. != ""]) and contains(sDescription, xdXDocument:get-DOM()/my:myFields/my:field2[. != ""])]


    Perhaps it really is a simple as a missing white space but I know not where!

    Many thanks again for your response.
  • 03-08-2007 04:03 PM In reply to

    Re: Filtering repeating table with secondary datasourc

    I don't see anything right off with your XPath, except for that if the XPath is contained in quotes, that you account for that by replacing double-quotes with single-quotes or using " instead.

    However, it might just be a logic flaw. Perhaps try the following instead:

    xdXDocument:GetDOM("Secondary Datasource")/Group1/Group2[xdXDocument:get-DOM()/my:myFields/my:field1 != "" and xdXDocument:get-DOM()/my:myFields/my:field2 != "" and contains(Code, xdXDocument:get-DOM()/my:myFields/my:field1) and contains(sDescription, xdXDocument:get-DOM()/my:myFields/my:field2)]

    What this does is first verify that the 2 fields are not blank and then if that is true for both, it continues with the contains() comparisons.
  • 03-09-2007 02:43 AM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Filtering repeating table with secondary datasourc

    Greg,

    I have tried various changes to get this filter to work. I tried your approach and have also replaced the quotes with
    "
    but that failed without an error message. It keeps coming back to the "Required white space was missing" message.

    <xsl:for-each select="xdXDocument:GetDOM("Secondary Datasource")/Group1/Group2[contains(Code, xdXDocument:get-DOM()/my:myFields/my:field1[. != ""]) and contains(sDescription, xdXDocument:get-DOM()/my:myFields/my:field2[. != ""])]


    This really has me scratching my head. Is there any tool that anyone could recommend that can be used to validate such filters?

    Thanks
  • 03-09-2007 05:55 AM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Filtering repeating table with secondary datasourc

    I have found the problem.

    The last square bracket on the line I posted here should not have been present. I was cutting and pasting my different attempts to keep track of changes. At some stage Infopath adds further filter information and moves the square bracket to the end. My cutting and pasting meant I was placing an extra square bracket in the middle of the filter. The ] in red was what done it!

    Greg, thanks again for your help.

    xdXDocument:GetDOM("Secondary Datasource")/Group1/Group2[contains(Code, xdXDocument:get-DOM()/my:myFields/my:field1[. != ""]) and contains(sDescription, xdXDocument:get-DOM()/my:myFields/my:field2[. != ""])] or ($filterParentHasNewRowsCTRL23 = "true" and xdXDocument:GetNamedNodeProperty(., "filterVersion", "0") > $filterParentVersionCTRL23)  ]
  • 03-09-2007 09:52 AM In reply to

    Re: Filtering repeating table with secondary datasourc

    I'm glad you were able to get it working! and glad that I could help!
  • 03-10-2007 12:02 PM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Filtering repeating table with secondary datasourc

    I have another hurdle. Now I have got the filter working I am looking to have data copied from the selected row. I know how to do this for repeating tables bound to the forms datasource but this cannot be applied to secondary datasource.

    Any ideas?

    Thanks
  • 03-12-2007 09:08 AM In reply to

    Re: Filtering repeating table with secondary datasourc

    What kind of copying are you talking about?

    Will the user be clicking a button? If so, rules should work just fine.

    Are you using code? If so, you just need to get the DOM of the secondary data source and then do the selectSingleNode() as you normally would.
  • 03-26-2007 11:38 PM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Filtering repeating table with secondary datasourc

    I have only just got back to this project,hence my delay in responding.

    This is a search function l am developing. A code is entered into the search field which is then used as the filter for a repeating table bound to the secondary datasource. For reasons I cannot recall now I couldn't get a master \detail relationship working here so I created separate fields outside of the table which I want to be automatically populated whenever the selection / focus within the repeating table changes.

    I suspect this needs to be code using the oncontextchange event?

    Thanks Spudy.
  • 03-27-2007 09:49 AM In reply to

    Re: Filtering repeating table with secondary datasourc

    Code might be your best choice here. OnContextChange works, but if it just needs to occur when a value changes, then use OnAfterChange instead.
  • 03-28-2007 12:12 AM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Filtering repeating table with secondary datasourc

    When a row is selected from the repeating table there are other fields outside of the table I wish to be populated with data.
    The data is from secondary data source that isn't to be altered.

    The data validation has only 'onafterchange' available from the individual data fields within the table.
    Can I just change the code to contextchange?

    Even so I used the on afterchange event to test;

    XDocument.DOM.selectSingleNode("//my:Selected").text = xdXDocument:GetDOM("ds2")/Group1/Group2/Code[../ID = current()];

    From the error informing that template was not valid and
    "expected ;" there is evidently something fundamentally wrong with this.

    many thanks

    Spudy
  • 03-28-2007 10:27 AM In reply to

    Re: Filtering repeating table with secondary datasourc

    If you go to the data source task pane you can create an OnAfterChange event for the table row (i.e. the node that holds all the row fields), if that is more useful to you.

    xdXDocument is not a valid object in code.

    Your attempting to use current() in the XPath will not work because there is no real context for it. What are you expecting current() to point to?
    In code it is better to be more explicit... for example:

    var selected = XDocument.DOM.selectSingleNode("//my:Selected");
    if(selected != null)
    {
    var id = selected.selectSingleNode("ID");
    var code = XDocument.GetDOM("ds2").selectSingleNode("/Group1/Group2[ID = '" + id + "']/Code");

    if(code != null)
    {
    selected.text = code.text
    }
    }
  • 03-28-2007 02:26 PM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Filtering repeating table with secondary datasourc

    Greg I am confused by your last reply.

    When a particular row of the table (populated from secondary ds) is
    selected by the user I want to identify the ID of that particular
    row of the table - hence why I am trying to use current() to capture
    the ID to populate fields within the main datasource of the form.

    Spudy
  • 03-28-2007 04:44 PM In reply to

    Re: Filtering repeating table with secondary datasourc

    Then I'm confused -- because yo are mixing two different worlds in your first posting: Code-XPaths and View-XPaths

    If you are trying to do all this in the designer, then you should not be doing any selectSingleNode anything.

    If you are doing this all in code, then you cannot use xdXDocument -- it doesn't exist.

    What I provided was an all code solution (though you probably need to modify it a bit to fit your particular scenario).
Page 1 of 1 (15 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.