This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Sep 10, 2011, 9:42 AM
14 Posts
topic has been resolvedResolved

repeated dataTable: hide dataTable completely if no content

  • Category: Other
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: xpages,Repeat Control,Data Table
  • Replies: 2
Hi,
trying to display search results from several other databases leads to a minor problem:

The caption of all dataTables are displayed, even if there are no matching documents.
But I want the dataTable to be hidden completely in this case.
I have tried the "rendered" property, but there the computed value is unavailable.

To avoid double searching, how could I compute the search result collection in the beginning of the reapeat to be usable as "this:data" and for calculating "rendered"?

Thanks in advance,
  Bernd

The source of my custom control:
 <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom"
    xmlns:xe="http://www.ibm.com/xsp/coreex">
    <xp:this.dataContexts>
        <xp:dataContext var="newsSearchStr">
            <xp:this.value><![CDATA[#{javascript:"[Modifed]>="+sessionScope.conf.app.newsDateQry}]]></xp:this.value>
        </xp:dataContext>
    </xp:this.dataContexts>
    <xp:panel id="centerArea">
        <xp:div styleClass="viewHeader">
            <xp:text escape="true" id="computedField2">
                <xp:this.value><![CDATA[#{javascript:var appObj = sessionScope.conf.app;
"Modified entries since " + appObj.newsDays + " days"}]]></xp:this.value>
            </xp:text>
        </xp:div>

        <!-- *** repeat over all news databases array *** -->
        <xp:repeat id="repeatDbs" rows="100"
            value="#{sessionScope.conf.dbsNews}" var="newsDbObj" indexVar="idxNewsDb">

            <!-- search in xpAllDocs since sessionScope.conf.app.newsDate -->
            <xp:dataTable id="dataTable1" rows="3000" indexVar="dtIdx"
                var="dtVar" caption="#{javascript:newsDbObj.dbShort}">
                <xp:this.value><![CDATA[#{javascript:// ...db.ftSearch TODO: should be view.FTSearch()
var db:NotesDatabase = session.getDatabase("", newsDbObj.dbPath);
if (db && db.isOpen()) {
    var coll = db.FTSearch(newsSearchStr);
}else {
    var coll = null;
}
coll}]]></xp:this.value>
                <xp:column id="column1" style="width:50px;">
                    <xp:text escape="true" id="computedField4"
                        value="#{dtIdx}">
                    </xp:text>
                </xp:column>
                <xp:column id="column2">
                    <xp:link escape="true" id="link1">
                        <xp:this.text><![CDATA[#{javascript:dtVar.getItemValueString("Subject")}]]></xp:this.text>
                        <xp:this.value><![CDATA[#{javascript:"/xpMainTopic.xsp"}]]></xp:this.value>
                        <xp:this.parameters>
                            <xp:parameter name="action" value="openDocument">
                            </xp:parameter>
                            <xp:parameter value="#{javascript:newsDbObj.dbPath}"
                                name="databaseName">
                            </xp:parameter>
                            <xp:parameter name="documentId">
                                <xp:this.value><![CDATA[#{javascript:dtVar.getUniversalID()
}]]></xp:this.value>
                            </xp:parameter>
                        </xp:this.parameters>
                    </xp:link>
                </xp:column>
            </xp:dataTable>
        </xp:repeat>
    </xp:panel>
</xp:view>

Sep 14, 2011, 12:18 PM
261 Posts
Re: repeated dataTable: hide dataTable completely if no content
 If the rendered property doesn't work for you (although it should), you could always wrap the datatable in an <xp:div> and set the rendered property on that component.
 
To check if there are results to display in the datatable you can use
 
getComponent("yourDataTableId").getRowCount() > 0 
 
Mark 
Sep 15, 2011, 5:59 AM
14 Posts
Re: repeated dataTable: hide dataTable completely if no content
Thank you, Mark
 
After adding
<xp:this.rendered>
     <![CDATA[#{javascript:getComponent("dataTable1").getRowCount() > 0 }]]>
</xp:this.rendered> 
to the dataTable, it works perfectly :-)
 
I still have to learn a lot about components...
 
Regards,
  Bernd

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal