如何在点击事件时让寻呼机返回第一页

如何在点击事件时让寻呼机返回第一页

本文介绍了如何在点击事件时让寻呼机返回第一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 xpage,带有一个名为 dynamicViewPanel1 的动态视图面板,它根据取消记录视图和未取消记录视图之间的单选按钮组选择而变化.该页面包括一个寻呼机以前进到下一页等.这一切正常.但是,我想要的是在通过单选按钮更改视图时让寻呼机返回第一页.我已经尝试了下面的代码,因为它是我目前在互联网上可以找到的所有代码.基本上,如果用户位于已取消"视图的第 2 页,然后通过单击单选按钮切换到未取消"视图,则会打开第 2 页上的未取消"视图并且不会返回到第 1 页.但是为什么下面的代码不起作用?

I have an xpage with a dynamic view panel named dynamicViewPanel1 which changes depending on the radio button group selection between Views of Cancelled records and Not Cancelled records. The page includes a pager to advance to next pages etc. This all works fine. However, what I want is to have the pager return to the first page when the view is changed via the radio button. I have tried the code below as its all I can find so far on the internet. Basically if a user is on page 2 of the "Cancelled" view and then chnages to the "Not Cancelled" view by clicking on the radio button, it opens the "Not Cancelled" view on page 2 and does not return to page 1. But why won't this code below work?

我也尝试过gotoPage(0)"而不是goToFirstPage()".我也尝试将 getComponent("conflictPager") 更改为 getComponent("dynamicViewPanel1")

I have also tried "gotoPage(0)" instead of "goToFirstPage(). I also tried changing getComponent("conflictPager") to getComponent("dynamicViewPanel1")

为了澄清,我已经包含了更多的页面代码.btnRefresh 是在单选组事件上激活的隐藏按钮,以确保页面刷新.

I have included more of the page code for clarification. The btnRefresh is a hidden button activated on the radio group event to ensure the page refreshes.

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

推荐答案

我使用

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>

这篇关于如何在点击事件时让寻呼机返回第一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 22:44