DropDown List -browser compatible - InfoPath Dev
in

InfoPath Dev

Having trouble finding a blog or post that answers your question? Check out our Custom Search Page

DropDown List -browser compatible

Last post 08-20-2012 03:30 AM by Gennady Vanin (Геннадий Ванин, Новосибирск). 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 08-19-2012 05:01 AM

    DropDown List -browser compatible

    Hi,

    I have a SharePoint list with fields: "DisplayName","Value","Type". the list should populate several drop downs in an Info path 2007 browser-compatible form.

    •  The type determines to which drop down the data should be populated to.
    •  I Can't filter the data from the list on the design because it's a browser compatible form.
    •  The request was not to separate the data into several lists.
    •  I have tried to use code behind with some success, but it seems too much to do for such a small request(code is below)

    is there a Proper\Normal way to do it?

    private string GetFieldName(XPathNavigator DS)

            {

                string displayName = DS.SelectSingleNode("@Name", NamespaceManager).Value;

                return displayName;

            }       

            private string GetFieldValue(XPathNavigator DS)

            {

                string value = DS.SelectSingleNode("@Value", NamespaceManager).Value;

                return value;

            }        

            public void InternalStartup()

            {

                FillDropDown("Type1");

            }

            private void FillDropDown(string DropDownName)

            {

                        XPathNodeIterator ProjectSites =

                    DataSources["OptionList"].CreateNavigator().Select(String.Format("/dfs:myFields/dfs:dataFields/dfs:OptionList[@Type='{0}']", DropDownName), NamespaceManager);            

                RemoveFirstItem(DropDownName);           

                foreach (XPathNavigator ProjectSite in ProjectSites)           

                {

                    string Val = GetFieldValue(ProjectSite);

                    string DisplayName = GetFieldName(ProjectSite);

                    AddItem(DropDownName,Val, DisplayName);

                } 

            }

            private void RemoveFirstItem(string DropDownName)

            {

                XPathNavigator DOM = MainDataSource.CreateNavigator();

                XPathNavigator group1 = DOM.SelectSingleNode(String.Format("/my:myFields/my:{0}", DropDownName), NamespaceManager);

                group1.MoveToFirstChild();

                group1.DeleteSelf();

            }

            private void AddItem(string DropDownName,string itemId, string itemName)

            {

                XPathNavigator DOM = this.MainDataSource.CreateNavigator().SelectSingleNode(String.Format("/my:myFields/my:{0}", DropDownName), NamespaceManager);

                XPathNavigator XClone = DOM.Clone();

                XClone.SelectSingleNode(String.Format("/my:myFields/my:{0}/my:DisplayName",DropDownName), NamespaceManager).SetValue(itemName);

                XClone.SelectSingleNode(String.Format("/my:myFields/my:{0}/my:Value", DropDownName), NamespaceManager).SetValue(itemId);

                DOM.InsertAfter(XClone);          

            }
  • 08-19-2012 08:53 AM In reply to

    Re: DropDown List -browser compatible

     The proper/normal way to do something in Infopath especially  with sharepoint list(s) is without code behind, i.e. by using rules and formulas.

     At least, I do not see anything in your post that would have dictated the use of code-behind.

    BTW, custom Infopath code is not supported for Sharepoint List Form type of of Infopath forms.
    This does not mean that it is impossible to communicate to/from sharepoint lists from other types of Infopath forms where having custom code is possible but not for changing list(s) from code behind.

     

    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
  • 08-19-2012 08:59 PM In reply to

    Re: DropDown List -browser compatible

     Wanted to ask it immediately and this desire has not faded away with time...

    What do you mean under your phrase:

    daniweb:
    I Can't filter the data from the list on the design because it's a browser compatible form

    ?

     

    IMO, OOTB the data to Infopath fOrm fRom a list is pulled in its entirety and after that filters are applied.
    Or, it is possible to use a webservice to filter data on server side or dll, etc.

    In any case I do not see why filtering is impossible in an Infopath browser form or even how it is different in an Infopath browser form from a client/Filler form.

    Can you give more details on your statement?

    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
  • 08-19-2012 11:01 PM In reply to

    Re: DropDown List -browser compatible

     Hi Genady,

    First of all 10x for the reply and spending some time to answer.

    I'm attaching a screen shot to show you what I meant with the phrase of filter and browser compatible

    Can you please give me some details how to work with a list and several drop downs with the fields I mentioned before? what is the proper way to work this out?

    thanks in advance.

    Dan

    Image 

     filter list on browser compatible form

     

     

  • 08-20-2012 02:33 AM In reply to

     Hello, Dan,

    Ithis depends on requirements and overall functionality but the most simple method is to created a receive data connection to a sharepoint list when I choose radiobutton "Get  choices from an external data source" (or doing it separately through Data Connections and then just choosing already created data source/connection), this provides possibility to choose a list's field(s) in "Display name":" and "Value:"

     Or external data source can be quite different, there are options for creating a data connection:

    • SOAP Web service 
    • REST Web service 
    • Sharepint Library or list
    • Database (Microsoft SQL Server only( 
    • XML document

     Select the source of your data

     

    I used all of them but have never seen such kind of error...

    Though I am using Infopath Designer 2010....

     


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

    Re: DropDown List -browser compatible

     Hi,

    I'm using info-path 2007, when I wanted to filter a list with no browser compatible option it filtered OK, also in the documentation of Info path it is mentioned that it can't be done.

    what do you think can be the  solution or the correct method to go with.

    TIA

  • 08-20-2012 03:30 AM In reply to

    Re: DropDown List -browser compatible

     Here was a reply to a  similar question , it seems to me

    If it is so troublesome in 2007, why not to try 2010?

    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
Page 1 of 1 (7 items)
Copyright © 2003-2012 Qdabra Software. All rights reserved.
View our Terms of Use.