2016-12-30 55 views
0

我有一个组合框,一个按钮和一个用于搜索功能的视图。该视图有两列,分别是类别和课程。在课程栏中,我设置多值分隔符为“新行”,启用“多个值作为单独的条目”,并且这两个视图列标题都是排序列。因此,当使用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> 

感谢您的咨询。谢谢。

回答

0

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

希望帮助

+0

Hello @stwissel,感谢您的回答和[文章](http://www.notessensei.com/blog/2009/07/showing-categorized-views-in-web-applications.html)。在这篇文章中,虽然在我的案例中没有总数,但我注意到“数据行在三个类别上的透视视图”是最相似的。有一件事我不明白如何显示单个数据行。在视图属性中,我没有找到实现该选项的选项。我更新了代码,也许我在代码中犯了错误?请介意看看并感谢您的建议。非常感谢你。 – beginner

0

的viewPanel中是非常有限的组成部分,目的是使页面上的基本视图控件。如果您想要更复杂或更灵活的布局,最好的方法是使用重复控制。

你可能试图强制View Panel给你想要的功能比用重复控制(也可以将dominoView作为数据源)构建布局要复杂得多。