Drop Down List - InfoPath Dev
in

InfoPath Dev

Drop Down List

Last post 12-20-2005 05:58 AM by nukkumatti. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 12-19-2005 07:54 AM

    Drop Down List

    Hi Folks,

    i already found some threads about drop down lists here. seems that i am not the only one who has some problems with it. i actually works fine except one thing.

    i used an infopath form with a repeating table to create a datasource. one field is called DisplayName (i.e. Design Layout) and the other Value (i.e. 24 hours). so the structure is:
    requestTypes (secondary), myFields, group1, group2,DisplayName - Value
    Then in my actual infopath form i used the "look up values in a dataconnetion to..." option. this works and i can see the display names in my drop down list.

    furthermore i have two textboxes. the one is directly bound to the drop down list which shows then the values from each selected DisplayName.
    In the other textbox (different View) i would like to show the display names selected in the dropdown list.
    First i wanted to solve that with using the OnAfterChange event (c# code) but it seems that the trigger doesn't fire at all (not even with just some sample string) after selecting something form the ddl.
    Now i read that i can also use a formula (textbox field) but i don't know what to put in there.
    Could somebody please help me out ?
    Thx in advance.


    Listen to Motörhead cos they play Rock'n Roll :)
    Listen to Motörhead cos they play Rock'n Roll :)
  • 12-19-2005 08:16 AM In reply to

    The simplest method to accomplish this task would be to utilize the formula box of the text box in your "different View".

    1. Double-click on the text box which you wish to populate with the DisplayName
    2. Click on the Fx (function) button in the Default Value section.
    3. Check the box labeled Edit XPath (advanced)
    4. Replace the contents of the Formula textbox with the following code (be sure to customize for your DOM):

    xdXDocument:GetDOM("NameOfSecondaryDataSource")/ns1:myFields/ns1:group1/ns1:group2[ns1:Value = //my:DropDownList]/ns1:DisplayName


    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 12-19-2005 08:30 AM In reply to

    Hi again,

    first of all thank you for help.
    i put the formula into my textbox and customized it to my dom. no error message but when previewing the form and selecting something from the ddl nothing appears in my textbox. any further suggetions.

    by the way i almost had the same solution like yours but that part was missing:[ns1:Value = //my:DropDownList].
    Do you have a short explanation for me ?

    Thx again in advance

    Listen to Motörhead cos they play Rock'n Roll :)
    Listen to Motörhead cos they play Rock'n Roll :)
  • 12-19-2005 11:09 AM In reply to

    This is weird, I don't know why the XPath function isn't working. I tried several different variations and could not get it to work. Maybe this is a bug, does anyone else know how to do this without using code?

    To do it using code, add the following to the OnAfterChange() event of the drop-down list box:

    	// match condition
    var value = eventObj.Source.text;
    // what we want to put into the text box
    var displayName = XDocument.GetDOM( "NameOfSecondaryDataSource" ).selectSingleNode( "/ns1:myFields/ns1:group1/ns1:group2[ns1:Value = " + value + "]/ns1:DisplayName" ).text;
    // set the textbox
    XDocument.DOM.selectSingleNode( "/my:myFields/my:TextBoxOnDifferentView" ).text = displayName;


    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 12-19-2005 11:52 PM In reply to

    Hi again,

    ok i really tried every combination with the textbox fromula but i didn't work. now i am using the OnAfterChangeEvent from the drop down list but unfortunately i always get this error when previewing the form and making a selection from the ddl.

    System.Runtime.InteropServices.COMException
    Expected token ']' found 'NAME'.

    /myFields/group1/group2[Value = 24-->hours<--]/DisplayName
    at Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMNode.selectSingleNode(String queryString)
    at Microsoft.Office.Interop.InfoPath.SemiTrust.DOMDocument50Wrapper.selectSingleNode(String queryString)
    at Microsoft.Office.Interop.InfoPath.SemiTrust.DOMDocument50Wrapper.selectSingleNode(String queryString)
    at Quotation_Application_Review.Quotation_Application_Review.ddlRequestType_OnAfterChange(DataDOMEvent e) in c:\documents and settings\jlorig\my documents\visual studio projects\quotation_application review\formcode.cs:line 101
    at Microsoft.Office.Interop.InfoPath.SemiTrust._DataDOMEventSink_SinkHelper.OnAfterChange(DataDOMEvent pDataDOMEvent)


    Here is the code i am using:
    [InfoPathEventHandler(MatchPath="/my:myFields/my:ddlRequestType", EventType=InfoPathEventType.OnAfterChange)]
    public void ddlRequestType_OnAfterChange(DataDOMEvent e)
    {
    // Write code here to restore the global state.


    if (e.IsUndoRedo)
    {
    // An undo or redo operation has occurred and the DOM is read-only.
    return;
    }
    // A field change has occurred and the DOM is writable. Write code here to respond
    // to the changes.
    string val = e.Source.text;
    IXMLDOMDocument3 displayName = (IXMLDOMDocument3)thisXDocument.GetDOM("requestTypes");
    //displayName.setProperty("SelectionNamespaces", displayName.getProperty("SelectionNamespaces"));
    string displayNameString = displayName.selectSingleNode("/myFields/group1/group2[Value = " + val + "]/DisplayName" ).text;
    // set the textbox
    IXMLDOMNode nodeRequest = thisXDocument.DOM.selectSingleNode("my:myFields/my:requestTest");

    nodeRequest.text = displayNameString;
    }


    Can someone help ?
    Thx in advance

    Listen to Motörhead cos they play Rock'n Roll :)
    Listen to Motörhead cos they play Rock'n Roll :)
  • 12-20-2005 05:58 AM In reply to

    Ok,

    got it working now. Added an additional node into my xml data source and use the value as a kind of counter value.
    Thx again for help Matt.

    Come back to you again at a later point with some more challanging questions :)

    Listen to Motörhead cos they play Rock'n Roll :)
    Listen to Motörhead cos they play Rock'n Roll :)
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.