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
***************************************************************************************************************