搜索时显示每行中的值

时间:2016-12-30 07:14:13

标签: xpages

我有一个组合框,一个按钮和一个搜索功能视图。视图有两列,分别是Category和Course。在“课程”列中,我将多值分隔符设置为“新行”,启用“多个值作为单独的条目”,并且两个视图列标题都是排序列。因此,当使用Internet Explorer查看应用程序时,视图如下所示:

Category                |   Course
-------------------------------------------------------              
Accounting              |   Advanced Accounting
Accounting              |   Introduction to Accounting
Accounting              |   Communication Skills
Accounting              |   Writing Skills
Engineering             |   Advanced Engineering
Engineering             |   Introduction to Engineering
Engineering             |   Communication Skills
Engineering             |   Writing Skills
Information Technology  |   Advanced Information Technology
Information Technology  |   Introduction to Information Technology
Information Technology  |   Communication Skills
Information Technology  |   Writing Skills

(更新)

谢谢stwissel的回答,我删除了按钮,因此有一个组合框和一个被分类的视图。虽然我在视图属性中找不到“LimitToCategory”(感谢有人让我知道在哪里找到它),但我从组合框中获取值并将其放入“按类别名称过滤”,组合框也有onchange事件和部分更新视图。

我运行程序,当我选择一个类别时,视图可以显示与该类别相关的相关值。想象一下,视图显示的结果如下:

Category                |   Course
-------------------------------------------------------              
Information Technology  |   Advanced Information Technology
                            Introduction to Information Technology
                            Communication Skills
                            Writing Skills

但是如何单独显示课程?我怎样才能使课程显示个别行? (请参阅下面的示例)

 Category                |   Course
----------------------------------------------------------              
 Information Technology  |  Advanced Information Technology
----------------------------------------------------------
 Information Technology  |  Introduction to Information Technology
----------------------------------------------------------
 Information Technology  |  Communication Skills
----------------------------------------------------------
 Information Technology  |  Writing Skills
----------------------------------------------------------

我在此帖xpages view panel column multivalue separator中添加了另一个customerConverter,但结果仍然相同。

 Category                |   Course
----------------------------------------------------------              
 Information Technology  |  Advanced Information Technology
----------------------------------------------------------
 Information Technology  |  Introduction to Information Technology
----------------------------------------------------------
 Information Technology  |  Communication Skills
----------------------------------------------------------
 Information Technology  |  Writing Skills
----------------------------------------------------------

我附上完整的代码供您审核。

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" dojoTheme="true">
<xp:this.resources>
    <xp:dojoModule name="dijit.form.ComboBox"></xp:dojoModule>
</xp:this.resources>
<xp:comboBox id="comboBox2" dojoType="dijit.form.ComboBox"
    style="width:400.0px" value="#{sessionScope.category}">
    <xp:selectItems>
        <xp:this.value><![CDATA[#{javascript:

var SetFirstValueBlank = @Text("");

return SetFirstValueBlank;
}]]></xp:this.value>
    </xp:selectItems>
    <xp:selectItems>
        <xp:this.value><![CDATA[#{javascript:@Unique(@DbColumn(@DbName(), "CategoryListView", 1));}]]></xp:this.value>
    </xp:selectItems>
    <xp:eventHandler event="onchange" submit="true"
        refreshMode="partial" refreshId="viewPanel5">
    </xp:eventHandler>
</xp:comboBox>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:viewPanel rows="30" id="viewPanel5">
    <xp:this.facets>
        <xp:pager partialRefresh="true" layout="Previous Group Next"
            xp:key="headerPager" id="pager5">
        </xp:pager>
    </xp:this.facets>
    <xp:this.data>
        <xp:dominoView var="view2"
            viewName="CategoryCourseView2">

            <xp:this.categoryFilter><![CDATA[#{javascript:getComponent("comboBox2").getValue();}]]></xp:this.categoryFilter>
        </xp:dominoView>
    </xp:this.data>
    <xp:viewColumn columnName="Category" id="viewColumn9"
        rendered="false">

        <xp:this.converter>
            <xp:customConverter
                getAsObject="#{javascript:return value;}">
                <xp:this.getAsString>
                    <![CDATA[#{javascript:return @Implode(value, "<br  />")}]]>
                </xp:this.getAsString>
            </xp:customConverter>
        </xp:this.converter>

        <xp:viewColumnHeader value="Category"
            id="viewColumnHeader9">
        </xp:viewColumnHeader>
    </xp:viewColumn>

    <xp:viewColumn id="viewColumn11" columnName="$10"
        contentType="HTML">
        <xp:this.facets>
            <xp:viewColumnHeader xp:key="header"
                id="viewColumnHeader11" value="Category">
            </xp:viewColumnHeader>
        </xp:this.facets>
    </xp:viewColumn>
    <xp:viewColumn columnName="CourseName" id="viewColumn10"
        contentType="HTML">

        <xp:this.converter>
            <xp:customConverter
                getAsObject="#{javascript:return value;}">
                <xp:this.getAsString>
                    <![CDATA[#{javascript:return @Implode(value, "<br />")}]]>
                </xp:this.getAsString>
            </xp:customConverter>
        </xp:this.converter>

        <xp:viewColumnHeader value="Course"
            id="viewColumnHeader10">
        </xp:viewColumnHeader>
    </xp:viewColumn>
</xp:viewPanel>
</xp:view>

请感谢您的建议。谢谢。

2 个答案:

答案 0 :(得分:0)

从下拉列表中选择值时,实际上是执行过滤器而不是搜索。在XPages中,您可以将视图分类并将LimitToCategory的值计算为下拉值 - 您可以直接指向该属性中的值。 你甚至不需要按钮。对于一些设计灵感,请参阅this article

希望有所帮助

答案 1 :(得分:0)

ViewPanel是一个非常有限的组件,旨在为页面提供基本的视图控件。如果您想要更复杂或更灵活的布局,最好的方法是使用重复控制。

您可能试图强制View Panel为您提供所需的功能比使用重复控件构建布局要复杂得多(也可以将dominoView作为数据源)。 / p>