Updating view.xsl file - InfoPath Dev
in

InfoPath Dev

Updating view.xsl file

Last post 07-14-2005 04:43 PM by reetus. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 07-13-2005 04:56 PM

    • reetus
    • Not Ranked
    • Joined on 07-06-2005
    • USA
    • Posts 9

    Updating view.xsl file

    Hi All,

    I have a dopdown list box called drpClient on infopath form which displays the Client Names from the Sharepoint list. Depending on the Client selected I need to populate the projects related to that Client in a listbox called lstProjects. The data in the lstProjects listbox is retrieved from the Sharepoint list. I have a filter on the lstProjects listbox which displays the projects depending on the Client selected.

    Problem:

    Now if a user selects a projects in the lstProjects listbox I would like to move that selected project in another listbox called
    lstSelectedProjectsListbox.

    I have changed the view.xsl file which would display the
    lstSelectedProjectsListbox as Preserve Code block. I thougt I do not have make any changes for the lstProjects listbox in the view .xsl file since my data is populated when the form is loaded. All I thought that I can retrieve the selected value from the lstProjects lisbox and pass it to MoveListItem() function as listed below. But I am not able to add the selected value in the lstSelectedProjectsListbox. In the MovelistIem function listed below I get oFromItem as null.

    All I know that I have to modify the view.xsl file for the lstProjects listbox. But I dont know how to do that.

    I have listed the jscript functions and a part of data from the view.xsl file which lists the two listboxes.

    Thanks a lot for all the help.

    Regards,
    -Reetu

    function btnMoveRight::OnClick(eventObj)
    {
    try
    {
    var oFromList = oDOM.selectSingleNode("//my:lstprojects");

    // Here I have not changed the view.xsl file and hence I cannot use
    // Choice1.So i have replaced it by lstprojects.

    var oFromItem = oDOM.selectSingleNode("//my:lstprojects");
    // var oFromItem = oDOM.selectSingleNode("//my:Choice1");

    var oToList = oDOM.selectSingleNode"//my:lstSelectedProjects");
    // List2 is lstSelectedProjects listbox

    var oToItem = oDOM.selectSingleNode("//my:Choice2");

    moveListItem(oFromList, oFromItem.text, oToList, oToItem.text);
    }
    catch(ex)
    {
    XDocument.UI.Alert(ex.Message);
    }
    //oFromItem.text = "";
    }

    function moveListItem(oFromList, sFromItem, oToList, sToItem)
    {
    try
    {
    // Here the value of oFromItem is null.hence it does not execuute
    // the oToList.insertBefore stmt.

    var oFromItem = oFromList.selectSingleNode("my:Item[.='" + sFromItem + "']");
    var oToItem = oToList.selectSingleNode("my:Item[.='" + sToItem + "']");

    if(null != oFromItem)
    oToList.insertBefore(oFromItem, oToItem);
    }
    catch(ex)
    {}
    }

    **************************************************************************************************************
    data from view.xsl file

    ***************************************************************************************************************

    // This is the lstSelectedProjects listbox . I haven't made changes here referring the Greg Collins sample example called Moving Items between listboxes.

    <xsl:template match="my:Choice2" mode="xd:preserve">
    <div class="xdSection xdRepeating" title="" style="MARGIN-BOTTOM: 6px;WIDTH: 100%; HEIGHT: 321px" align="left" xd:xctname="Section" xd:
    CtrlId="CTRL2" tabIndex="-1">
    <div>
    <strong>Selected Projects list box</strong>
    </div>
    <div>
    <select class="xdListBox xdBehavior_Select" title="" size="3" xd:
    xctname="ListBox" xd:CtrlId="CTRL6" tabIndex="0" xd:binding="." xd:
    boundProp="value" style="WIDTH: 100%; HEIGHT: 263px">
    <xsl:attribute name="value">
    <!--<xsl:value-of select="my:Item"/> -->
    < xsl:value-of select="."></xsl:value-of>
    </xsl:attribute>

    <xsl:value-of select="xdExtension:populateListBox("//my:List2/my:Item", string(.))" disable-output-escaping="yes"></xsl:value-of>
    </select>
    </div>
    <div> </div>
    </div>
    </xsl:template>

    // This is the lstProjects listbox . I haven't made changes in
    // the .xsl file for this listbox.

    <xsl:template match="my:List1" mode="_1">
    <div class="xdSection xdRepeating" title="" style="MARGIN-BOTTOM: 6px; WIDTH:100%; HEIGHT: 320px" align="left" xd:CtrlId="CTRL1" xd:xctname="Section" tabIndex="-1">
    <div align="left">
    <strong>lst Projects</strong>
    <select class="xdListBox xdBehavior_Select" title="" style="WIDTH: 100%;HEIGHT: 277px" size="3" xd:CtrlId="CTRL5" xd:xctname="ListBox" value="" xd:boundProp="value" xd:binding="my:Item" tabIndex="0">

    <xsl:attribute name="value">
    <xsl:value-of select="my:Item"/>
    </xsl:attribute>

    <xsl:choose>
    <xsl:when test="function-available('xdXDocument:GetDOM')">
    <option/>
    <xsl:variable name="val" select="my:Item"/>

    <xsl:if test="not(xdXDocument:GetDOM
    "Clients")/dfs:myFields/dfs:dataFields/dfs:Clients/@ClientName[.=$val] or $val='')">

    <option selected="selected">
    <xsl:attribute name="value">
    <xsl:value-of select="$val"/>
    </xsl:attribute>
    <xsl:value-of select="$val"/>
    </option>
    </xsl:if>
    <xsl:for-each select="xdXDocument:GetDOM
    ("Clients")/dfs:myFields/dfs:dataFields/dfs:Clients/@ClientName">

    <option>
    <xsl:attribute name="value">
    <xsl:value-of select="."/>
    </xsl:attribute>
    <xsl:if test="$val=.">
    <xsl:attribute name="selected">selected</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="."/>
    </option>

    </xsl:for-each>
    </xsl:when>
    <xsl:otherwise>
    <option>
    <xsl:value-of select="my:Item"/>
    </option>
    </xsl:otherwise>
    </xsl:choose>
    </select>
    </div>
    <div> </div>
    <div> </div>
    </div>
    </xsl:template>

    **************************************************************************************************************
    end of data from view.xsl file

    ***************************************************************************************************************
  • 07-14-2005 12:54 AM In reply to

    Hi Reetus,
    This is a brief response for now as it's getting late here on the Pacific coast. It occurs to me that you are trying to implement some kind of multi-select functionality using multiple list boxes. Using your current approach, you might consider writing an OnContextChange event handler that captures the selection state of the second listbox and sets values in a secondary data source that is used as the source of your third dropdown. You can just add the selected items to a repeating element in the secondary data source. However, the problem is deselection. How do you remove an item from a list.

    Another approach to take is to use a repeating section with a checkbox for each element. You have a repeating group that contains a IsSelected boolean checkbox and the value of the field. You can't put this in a dropdown, but you can put the section in a row in a table in a scrolling section. Then, you can easily control deselection.

    Or, you could just take a look at our Smart Combo Box which supports multi selection in the lisbox and allows you to create a separate dropdown that binds to the selected values.

    Hope these ideas help.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 07-14-2005 10:06 AM In reply to

    • reetus
    • Not Ranked
    • Joined on 07-06-2005
    • USA
    • Posts 9
    Hi Patrick,

    Thanks a lot for your reply.

    I downloaded the Smart Combo box evaluation copy and followed the steps listed in the setup.txt file.I have a data connection called Clients in the InfoPath form which retrieves the values from Sharepoint list.On the Smart Combo box properties I selected the option “Look up values in the data connection.” And provided the details listed below.

    Data connection name: Clients
    Entries = "/dfs:myFields/dfs:dataFields/dfs:Clients"
    Value = "/dfs:myFields/dfs:dataFields/dfs:Clients/@ClientName"
    Display Name = "/dfs:myFields/dfs:dataFields/dfs:Clients/@ClientName"

    When I preview the form the combo box is empty.
    Can you please let me know if I am providing the incorrect values on the properties of the smart combo box.

    Thanks a lot for all your help.

    Regards,
    -Reetu

    Below I am listing the data from the view.xsl file

    <object class="xdActiveX" hideFocus="1" style="WIDTH: 192px; HEIGHT: 192px" classid="clsid:faf334df-d5eb-4d9b-87c6-5200b4cc40e0" tabIndex="0" tabStop="true" xd:xctname="{{faf334df-d5eb-4d9b-87c6-5200b4cc40e0}}" xd:CtrlId="CTRL1" xd:bindingType="text" xd:bindingProperty="Value" xd:boundProp="xd:inline" contentEditable="false" xd:binding="my:field1">
    <xsl:if test="function-available('xdImage:getImageUrl')">
    <xsl:attribute name="src"><xsl:value-of select="xdImage:getImageUrl(my:field1)"/></xsl:attribute>
    </xsl:if>
    <param NAME="_cx" VALUE="5080"/>
    <param NAME="_cy" VALUE="5080"/>
    <param NAME="Enabled" VALUE="0"/>
    <param NAME="URL" VALUE="Clients"/>
    <param NAME="XMLEntries" VALUE="/dfs:myFields/dfs:dataFields/dfs:Clients"/>
    <param NAME="XMLEntryValue" VALUE="/dfs:myFields/dfs:dataFields/dfs:Clients/@ClientName"/>
    <param NAME="XMLEntryName" VALUE="/dfs:myFields/dfs:dataFields/dfs:Clients/@ClientName"/>
    </object>
  • 07-14-2005 10:48 AM In reply to

    Hi Reetus,
    I'll ask support to reply to this today. Thanks for your patience.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 07-14-2005 11:38 AM In reply to

    • reetus
    • Not Ranked
    • Joined on 07-06-2005
    • USA
    • Posts 9
    Thanks a lot Patrick.

    Regards,
    -Reetu

  • 07-14-2005 12:06 PM In reply to

    • reetus
    • Not Ranked
    • Joined on 07-06-2005
    • USA
    • Posts 9
    Hi Patrick,

    If possible please try to answer my query below, because its been a week that I am struggling with it, but no luck.

    My requirement is similar to Greg Collins sample example "Moving Item between Listboxes". I created my own sample example to understand how "Moving Items between listboxes" example works.

    In that I found that the data in the listbox in populated from the template.xml file. In short I can modify the data in template.xml file and that data would be seen in the left and right listbox.

    My requirement is:
    1)On load the left list box is populated based on a filter and right list box would be empty at that point. I know how to do this.
    2) When data from left listbox is selected move it to right listbox and remove it from left listbox.
    3) When data from right list box is selected move it to left list box and remove it from right list box.

    I followed the steps referring the sample example. Then I tried to preview the form. The left listbox was populated with the data from the filter specified but the control was disabled which means that I cannot select a value from the left listbox. Then I started thinking of different ways to modify the left listbox and still no luck.

    I have my own solution but it is not that neat and it is not very user friendly.

    It would be a biggggggggggg help if you can help me this.

    Regards,
    -Reetu
  • 07-14-2005 01:29 PM In reply to

    Hello Reetu,
    In answer to you first question about the smart combo box. Can you give a relative path for value and Display Name fields. Basically value and Displayname will contain the value @ClientName. This is similar to how list box works in InfoPath where you give the data connection name first, then the path to the repeating node in the Entries text box and then the relative path to the nodes you want to see in the value and display name text box.

    If this also does not help. Can you post a snippet of the xml file that is part of the data connection in this thread.

    About your second issue of seeing the list box disabled is because it is bound to a node that is not present in your xml. Take a look at the xd:preserve block in the xsl file - that should give you more data here.

    Shanthi
    InfoPathDev India
    Shanthi Reddy
  • 07-14-2005 01:50 PM In reply to

    • reetus
    • Not Ranked
    • Joined on 07-06-2005
    • USA
    • Posts 9
    Hi Shanthi,

    I tried the value @ClientName for Value and Display Name field but that didn't work either.

    >Can you post a snippet of the xml file that is part of the data >connection in this thread.

    I am not very clear from which file I am suppose to post the xml data.Below I am listing a snippet of View1.xsl file. But I am sure this is not what you are requesting for.

    I have the following files. Can you please tell from which file I am suppose to send the data.

    Clients.xsd
    myschema.xsd
    template.xml
    sampledata.xml
    view1.xsl

    Thanks for the help.

    Regards,
    -Reetu

    <div>
    <object class="xdActiveX" hideFocus="1" style="WIDTH: 192px; HEIGHT: 192px" classid="clsid:faf334df-d5eb-4d9b-87c6-5200b4cc40e0" tabIndex="0" xd:boundProp="xd:inline" xd:bindingProperty="Value" xd:bindingType="text" xd:CtrlId="CTRL1" xd:xctname="{{faf334df-d5eb-4d9b-87c6-5200b4cc40e0}}" tabStop="true" contentEditable="false" xd:binding="my:field1">

    <xsl:if test="function-available('xdImage:getImageUrl')">
    <xsl:attribute name="src"><xsl:value-of select="xdImage:getImageUrl(my:field1)"/></xsl:attribute>
    </xsl:if>

    <param NAME="_cx" VALUE="5080"/>
    <param NAME="_cy" VALUE="5080"/>
    <param NAME="Enabled" VALUE="0"/>
    <param NAME="URL" VALUE="Clients"/>
    <param NAME="XMLEntries" VALUE="/dfs:myFields/dfs:dataFields/dfs:Clients"/>
    <param NAME="XMLEntryValue" VALUE="@ClientName"/>
    <param NAME="XMLEntryName" VALUE="@ClientName"/>
    </object>
    </div>
  • 07-14-2005 03:30 PM In reply to

    • reetus
    • Not Ranked
    • Joined on 07-06-2005
    • USA
    • Posts 9
    Hi Shanthi,

    Below I have listed the xml data from Sampledata.xml file that contains data connection details

    Regards,
    -Reetu

    <my:myFields xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-07-14T16:43:18" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
    <my:field1/>
    <my:field2/>
    <xd:SchemaInfo LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-07-14T16:43:18">
    <xd:Namespaces>
    <xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-07-14T16:43:18"/>
    </xd:Namespaces>
    </xd:SchemaInfo>

    <xd:DataConnection Name="Clients">
    <dfs:myFields xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-07-14T16:43:18" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
    <dfs:dataFields>
    <dfs:Clients ClientName=""/>
    </dfs:dataFields>
    <xd:SchemaInfo LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution">
    <xd:Namespaces>
    <xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"/>
    </xd:Namespaces>
    </xd:SchemaInfo>
    </dfs:myFields>
    </xd:DataConnection>
    </my:myFields>
  • 07-14-2005 04:43 PM In reply to

    • reetus
    • Not Ranked
    • Joined on 07-06-2005
    • USA
    • Posts 9
    Hi Shanthi,

    Thanks for the reply before.

    Related to my second issue the left listbox is now enabled and I can select a value which needs to be added in the right list box.

    I need some help with an expression which I have listed below.

    The issue is oFromItem object is null when I am debugging the MovelistItem function which is listed below.
    I tried to debug further to see the values of oFromList object and I observed the following:

    a) The text property of oFromList object is empty because of which oFromItem object is returning Null. When I checked the ParentNode.text value of oFromList object it contains the correct value. The OwnerDocument.text property of oFromList object also contains the correct value.

    I need to change the following expression
    ("my:Item[.='" + sFromItem + "']") so that the object oFromItem is not null.

    var oFromItem = oFromList.selectSingleNode("my:Item[.='" +
    sFromItem + "']");

    In the expression how do I refer to ParentNode.text value of oFromList object so that oFromItem is not null?

    Thanks again for all your help.

    Regards,
    -Reetu

    function btnMoveLeft::OnClick(eventObj)
    {
    debugger;
    var oFromList = oDOM.selectSingleNode("//my:List2");
    var oFromItem = oDOM.selectSingleNode("//my:Choice2");
    var oToList = oDOM.selectSingleNode("//my:List1");
    var oToItem = oDOM.selectSingleNode("//my:Choice1");

    moveListItem(oFromList, oFromItem.text, oToList, oToItem.text);
    oFromItem.text = "";
    }


    function moveListItem(oFromList, sFromItem, oToList, sToItem)
    {
    debugger;
    try
    {
    var oFromItem = oFromList.selectSingleNode("my:Item[.='" +
    sFromItem + "']");
    var oToItem = oToList.selectSingleNode("my:Item[.='" + sToItem
    + "']");

    if(null != oFromItem)
    oToList.insertBefore(oFromItem, oToItem);
    }
    catch(ex)
    {}
    }
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.