Filtering two listboxes - InfoPath Dev
in

InfoPath Dev

Filtering two listboxes

Last post 11-03-2005 01:48 AM by potpourri. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-28-2005 03:06 PM

    • Idisis
    • Not Ranked
    • Joined on 04-28-2005
    • Posts 5

    Filtering two listboxes

    Hello all,

    I currently have two list boxes set up on my form (comp_name) and (version). comp_name reads from a sharepoint list of component names and their versions. This list could have multiple copies of the same component name.

    for example:
    Component Name Version
    Test_1 1.00
    Test_1 2.00
    Test_2 1.00

    What i need to do is have the comp_name list box filter out duplicate names and make it so when I change the comp_name listbox it will populate the version list box with all versions assigned to that comp_name.

    Right now I have created the following java scripts, but I am really not too sure where to go from here:

    function msoxd_my_comp_name::OnAfterChange(eventObj)
    {
    //gets the currently selected comp_name
    var componentField = XDocument.DOM.selectSingleNode("//my:comp_name").text;

    //queries the datasource for the components list from sharepoint
    var dataArray = XDocument.DataObjects("Components").DOM;

    //sets the namespaces to correspond to the sharepoint namespace format (??? i am guessing on this)
    dataArray.setProperty("SelectionNamespaces","xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution' xmlns:dsf='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution'");

    //selects all versions that are assigned to the component that is showing under the comp_name field
    var dataList = dataArray.selectSingleNode("/dfs:myFields/dfs:dataFields/dsf:Version[@Component='" + componentField + "']");
    }

    Any help would be greatly appreciated.

    Thanks,
    Ryan
  • 04-28-2005 10:23 PM In reply to

    Re: Filtering two listboxes

    Hi Ryan, Welcome to the board
    You need not write code in this scenario, you can solve this problem using xpath.

    Map comp_name list box to "dsf:Version"

    Have this filter on it "not(preceding-sibling::dsf:Version/@Component= @Component)". By doing this you are filering duplicates of the Components.

    Select "Value" and "Dispaly name" to be Component.

    Now you should not see any duplicate values in the Component list box.

    Hope this helps.



    Agni
    InfoPathDev India
  • 04-29-2005 07:16 AM In reply to

    • Idisis
    • Not Ranked
    • Joined on 04-28-2005
    • Posts 5

    Re: Filtering two listboxes

    Hi Agni,

    Ok I figured out how to apply filters, but I just cant seem to get the one you mentioned to work. I have my version listbox only display versions associated to the comp_name (thanks btw!), but I still cant get it to filter the comp_name listbox to omit duplicate records.

    Here is what I have tried:

    I place the following expression into the filter:
    not(preceding-sibling::dsf:Name/@Component= @Component)

    To my understanding we are saying, if the name of this data element is equal to the previous data element do not include it. Is that a correct assumption? When I place this code into the filter it tells me "Reference to undeclared namespace prefix: 'dsf'"... so by the look of it I think you just had a typo for the name space.

    I changed the code to the following:
    not(preceding-sibling::dfs:Name/@Component= @Component)

    Now i get the following message:
    "preceding-sibling::dfs:Name/@Component" does not point to a valid location path of a field or group.

    I currently have the listbox mapped to the Components secondary datasource, no to the Component/Name Datafield. I have also tried mapping it directly to the Name datafield but I get the same error.


    Thanks,
    Ryan
  • 11-03-2005 01:48 AM In reply to

    Re: Filtering two listboxes

    I have problems with applying filter as well :(

    This is the full XPath of the data source for filling in the drop-down:

    /dfs:myFields/dfs:dataFields/dfs:Requests_Sub_Types/@subType[../@listName = /dfs:myFields/dfs:dataFields/dfs:Form_Type/@subTypeList[../@formType = xdXDocument:get-DOM()/my:myFields/my:requestHeadingSection/my:formType]]

    I have a "Form Type" and "Sub Type" drop-downs and I wish to populate with values from sharepoint list "Requests_Sub_Types" from the attribute @subType.


    But I have no clue as where to apply the "not(preceding-sibling)" keyword :(


    Any one could help?
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.