2016-12-30 49 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作爲數據源)構建佈局要複雜得多。