我有一个名为dynamicViewPanel1的动态视图面板的xpage,该视图面板根据取消记录视图和未取消记录之间的单选按钮组选择而变化。该页面包括一个推进到下一页等的寻呼机。这一切都很好。但是,我想要的是当通过单选按钮更改视图时,寻呼机返回到第一页。我已经尝试了下面的代码作为我迄今为止在互联网上找到的所有内容。基本上,如果用户在“已取消”视图的第2页上,然后通过单击单选按钮选择“未取消”视图,则会打开第2页上的“未取消”视图,但不会返回到第1页。但为什么下面的代码不会起作用呢?
我也试过“gotoPage(0)”而不是“goToFirstPage()。我也尝试将getComponent(”conflictPager“)更改为getComponent(”dynamicViewPanel1“)
编辑:我已经包含了更多页面代码以供澄清。 btnRefresh是在无线电组事件上激活的隐藏按钮,以确保页面刷新。
<xp:panel>
<xp:label value="This page provides options to view records that are
cancelled or NOT cancelled, i.e. Open or Completed"
id="label5" style="font-weight:bold">
</xp:label>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:radioGroup id="rgDuplicates" defaultValue="0">
<xp:selectItem itemLabel="Not Cancelled" itemValue="0">
</xp:selectItem>
<xp:selectItem itemLabel="Cancelled" itemValue="1">
</xp:selectItem>
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[document.getElementById("#
{id:btnRefresh}").click()]]></xp:this.script>
</xp:eventHandler>
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:getComponent
("dynamicViewPanel1").gotoFirstPage()}]]></xp:this.action>
</xp:eventHandler></xp:radioGroup>
<xp:button value="Refresh" id="btnRefresh"
style="display:none">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
</xp:eventHandler>
</xp:button>
<xp:panel id="maincontentpanel">
<xe:dynamicViewPanel rows="30" id="dynamicViewPanel1"
width="100%" partialRefresh="true" showCheckbox="true">
<xe:this.data>
<xp:dominoView var="view">
<xp:this.viewName>
<![CDATA[#{javascript:if(getComponent("rgDuplicates").getValue
() == "0"){
viewName = "NotCancelled"
} else {
viewName = "Cancelled"
}}]]>
</xp:this.viewName>
</xp:dominoView>
</xe:this.data>
</xe:dynamicViewPanel>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:button value="Delete" id="delete">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action>
<xp:actionGroup>
<xp:confirm message="Are you sure?">
</xp:confirm>
<![CDATA[#{javascript:var viewPanel=getComponent
("dynamicViewPanel1");
var docIDArray=viewPanel.getSelectedIds();
for(i=0; i < docIDArray.length; i++){
var docId=docIDArray[i];
var doc=database.getDocumentByID(docId);
doc.remove(true);
}}]]>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:pager partialRefresh="true"
layout="Previous Group Next" xp:key="footerPager"
id="conflictPager" for="dynamicViewPanel1">
</xp:pager>
</xp:panel>
</xp:panel>
答案 0 :(得分:1)
我使用
工作了getComponent("dynamicViewPanel1").gotoFirstPage()
这是完整的代码
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:radioGroup id="rgDuplicates" defaultValue="0">
<xp:selectItem itemLabel="Not Cancelled" itemValue="0">
</xp:selectItem>
<xp:selectItem itemLabel="Cancelled" itemValue="1">
</xp:selectItem>
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:getComponent("dynamicViewPanel1").gotoFirstPage();}]]></xp:this.action>
</xp:eventHandler>
</xp:radioGroup>
<xe:dynamicViewPanel id="dynamicViewPanel1" rows="2">
<xe:this.data>
<xp:dominoView var="view1">
<xp:this.viewName><![CDATA[#{javascript:var c = getComponent("rgDuplicates").getValue()
if(c=="1"){
return "Start2"
}else{
return "start"
}
}]]></xp:this.viewName>
</xp:dominoView>
</xe:this.data>
</xe:dynamicViewPanel>
<xp:pager layout="Previous Group Next" partialRefresh="true" id="pager1" for="dynamicViewPanel1"></xp:pager>
</xp:view>