阻止javascript组件刷新我的整个页面



我正在将数据透视表.js(在这里阅读后 http://www.wissel.net/stw/wisselblog.nsf)添加到xPages应用程序中。组件加载,但是当允许过滤数据的组件在我的xPage上完成时,我遇到了问题,它会刷新整个页面而不仅仅是图表。

这是该应用程序的演示,您可以看到,当您点击类别的下拉菜单时,您可以进行过滤,一旦完成,它会进行部分刷新以过滤数据。http://nicolas.kruchten.com/pivottable/examples/mps.html

在我的xPage上,当我过滤数据时,它会刷新整个页面。有没有办法防止这种行为?

以下是相关代码。未包含的代码只是未经修改从项目中获取的,但如果需要,我可以包含。

我正在使用 xpage 上的自定义控件

<xc:ccPivot disableTheme="true"></xc:ccPivot></xp:view>

自定义控件内部没有太多内容。我尝试在页面底部调用脚本,但没有进行任何更改。

  <script type="text/javascript" src="callPivotTable"></script>
 <xp:this.resources>
    <xp:script src="/pivot.js" clientSide="true"></xp:script>
    <xp:styleSheet href="/pivot.css"></xp:styleSheet>
    <xp:script src="/jquery-ui-1.9.2.custom.min.js"
        clientSide="true">
        </xp:script>
        <xp:script src="/d3_renderers.js" clientSide="true"></xp:script>
     </xp:this.resources>
 <div id="output" style="margin: 10px;"></div>

这是调用数据透视表脚本

$(function(){
            var derivers = $.pivotUtilities.derivers;
            $.getJSON("./xRest.xsp/restService2", function(mps) {
                $("#output").pivotUI(mps                 
                );
            });
         });

你会注意到,我在这里没有调用jQuery作为资源。那是因为我使用的是加载jQuery的bootstrap4xpages扩展库。不确定这是否有区别。

这是工作 nsf 的链接。它使用引导扩展库和 bootstrapv2.3.2,但在 bootstrap3 中加载正常,但存在相同的问题。链接到NSF

无需

更改透视.js代码。当数据透视表在表单中呈现时,它根本不起作用。任何小部件刷新都会强制发布整个表单。无法通过代码更改使其工作,因此我关闭了表单生成,现在它按预期工作。

转到 XPage 属性("所有属性"选项卡)并将属性createForm设置为 false 。或者在源代码中它应该是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view
    xmlns:xp="http://www.ibm.com/xsp/core"
    xmlns:xc="http://www.ibm.com/xsp/custom"
    createForm="false">
    <xp:this.resources>
        <xp:script
            src="/pivot.js"
            clientSide="true">
        </xp:script>
        <xp:styleSheet
            href="/pivot.css"></xp:styleSheet>
        <xp:script
            src="/jquery-ui-1.9.2.custom.min.js"
            clientSide="true">
        </xp:script>
        <xp:script
            src="/jquery.ui.touch-punch.min.js"
            clientSide="true">
        </xp:script>
    </xp:this.resources>
    <xp:scriptBlock>
        <xp:this.value><![CDATA[$( function() {
    $("#output").pivotUI( [ {
        color : "blue",
        shape : "circle"
    }, {
        color : "red",
        shape : "triangle"
    } ], {
        rows : [ "color" ],
        cols : [ "shape" ]
    });
});]]></xp:this.value>
    </xp:scriptBlock>
    <div
        id="output"
        style="margin: 10px;">
    </div>
</xp:view>

最新更新