Welcome to the IBM Collaboration Solutions Community IQJam.
UsernamePassword
Reset Password | Register
   
Home | Leader Board | Tags | Help
How do I hide rows in a dataTable without incurring excessive <td><tr></tr></td> entries? 
I'll admit now to being a noob.  I'm an Admin with an interest in development (makes my job a whole lot easier if I understand the code behind the stuff I support).
 
I have an agent that generates XML output.  I have an Xpage that contains a data table that displays the XML output from the agent.
 
If I display the entire contents of the XML output, no problems.  But how do I display a subset of the XML content in the data table? 
 
Let me explain further.  Paul Calhoun submitted an excellent post about XML as a XPages data source  http://xpagesblog.com/xpages-blog/2009/8/6/using-xml-as-an-xpage-data-source.html

Using the advice given by Paul, and butchering it, I now have an Xpage, containing a dataTable control, containing a table. Including a table within the dataTable allows me to format the data from the XML as I require.
 
As mentioned before, displaying the entire XML in this way works brilliantly.  I have a fully rendered page, in the format that I want. 
 
However, I now want to display a subset of that data, records that meet a specific criteria, rather than displaying the full listing.
 
I thought I could do this by adding a  <this.rendered>....</this.rendered> section to the table, inside the <table> tag in the XPage source code.  This kind of works as I want, but the page is being rendered with extra <td><tr></tr></td> tags in the spaces where a table has been omitted due to not meeting the <this.rendered> criteria.
 
Viewing the source of the rendered page, I see something like this:

<tr><td><table> 
(various content from the XML)
</table></tr></td>
<tr><td><table>
(various content from the XML)
</table></tr></td>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td><table>
(various content from the XML)
</table></tr></td>

 Obviously, this messes up the whole look of the page.  I assume it has something to do with the fact that you invoke <dataTable> prior to parsing the XML values (ie you can't parse the XML values without invoking the <dataTable>). And that you can't determine if the <table> should be rendered without parsing the XML values first, meaning that <dataTable> is invoked (generating the initial <tr><td></td></tr> tags) even if <table> is not to be rendered.
 
Does this make sense?  If so, is there any way around it? 
 
Any assistance/advice would be appreciated, as would confirmation that my noob understanding of what is actually happening is correct.  At the same time, don't feel as though you need to spare my feelings.  I'm pretty thick skinned, so any criticism will not be taken badly, I promise.
 
If you need me to post some Source code, let me know.
 
Mark 
Domino Development / XPages
Tagged
Mark Rowan - about 1 year ago |  |  | Viewed 515 times

There are 5 answers

0votes
Hi Mark ...
 
If you change your entire <table> to an <xp:table>, and your <tr>'s to <xp:tr>'s, and your <td>'s to <xp:td>'s, you can access a rendered property for the entire table, row, and cell ... this should allow you to hide the rows you want to hide, without getting the extra tags.  (Also, you only need to hide the topmost element, anything within the hidden element will not render either .. so to hide the data, and the entire row, just modify the rendered value for the <xp:tr>)


Jeremy Hodge - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes

Hi Jeremy,
 
Thanks for your response.  I probably didn't make my point very well.   The source I included above is the rendered source, visible in the browser (right click>view source), not the source as it appears in DDE.
 
Referring to the XPage source, I have something like this at the top:

<xp:this.afterPageLoad><![CDATA[#{javascript://Create the XML Document
var parsedxml:org.w3c.dom.Document = null;
var domfactory:javax.xml.parsers.DocumentBuilderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
var xmldocument:javax.xml.parsers.DocumentBuilder = domfactory.newDocumentBuilder();
var parsedxml = xmldocument.parse("http://localhost/folder1/database.nsf/xmlagent.xml");
sessionScope.put("xmlfeed",parsedxml);}]]>
</xp:this.afterPageLoad> 

Further down the page I have this:
 
<xp:dataTable id="dataTable1" var="pernames" indexVar="rows" style="width:100.0%" rows="120">
 <xp:this.value><![CDATA[#{javascript:var domdoc:DOMDocument = sessionScope.get("xmlfeed");
 var dtvalues:DOMNodeList = domdoc.getElementsByTagName("Element1");
 return dtvalues;}]]></xp:this.value>
 <xp:column id="column1">
  <xp:table style="width:100%;font-size:8pt">
   <xp:this.rendered><![CDATA[#{javascript:var domdoc:DOMDocument = sessionScope.get("xmlfeed");
    var dtvalues:DOMNodeList = domdoc.getElementsByTagName("Element1");
    var nnode:DOMNode = dtvalues.item(rows);
    var displayentry:string = nnode.getFirstChild().getNodeValue();
    if (displayentry == "Domain1") {
     return true;
    } else {
     return false;
    };}]]>
   </xp:this.rendered>
   <xp:tr>
    <xp:td style="width:20.0%;font-weight:bold;background-color:rgb(0,128,192);color:rgb(255,255,255);text-align:left">
     Server Name:
    </xp:td>
    <xp:td style="width:80.0%;font-weight:bold;background-color:rgb(0,128,192);color:rgb(255,255,255);text-align:left">
     <xp:text escape="true" id="computedField33" style="font-weight:bold">
      <xp:this.value><![CDATA[#{javascript:var domdoc:DOMDocument = sessionScope.get("xmlfeed");
       var dtservers:DOMNodeList = domdoc.getElementsByTagName("Element2");
       var nnode:DOMNode = dtservers.item(rows);
       return nnode.getFirstChild().getNodeValue();}]]>
      </xp:this.value>
     </xp:text>
    </xp:td>
   </xp:tr>
  </xp:table>
 </xp:column>
</xp:dataTable>

 If I remove the <xp:this.rendered>...</xp:this.rendered> section, all records in the XML feed are rendered as I would expect.  It is only if the <xp:this.rendered>...</xp:this.rendered> section is left in (which will filter the XML feed and only display the desired records) that the problems occur.  I suspect it is because the <xp:this.value> appears within <xp:dataTable>

I've tried taking it outside of the <xp:dataTable> but then I get a 500 error.



Mark Rowan - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Mark,
 
Look on the xpages blog on the article for creating a dynamic HTML table here
 
 
The data table repeats the rows based upon the data where using the dynamic html solution you can control when the table elements are written to the output. 
 
Paul T. Calhoun 


Paul Calhoun - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Paul,
 
Thanks for the response.  Can you use your "dynamic html table" with an xml data source and still filter the displayed values?  I know it says on your page that you can use an xml feed, but your example in the database is based on a view (whiich has come in handy elsewhere I must add) so how would you restrict what was displayed (from an xml feed) in the table based on a given value?  I'm guessing it is possible but it's probably beyond my capabilities.

I'm toying with the idea of re-writing the xml feed to restrict the xml ouput to just include the values I want (based on the selection from a drop-down list) and then I can display all the returned values but I was hoping to use the full xml output (as is, without a re-write) and then just display the records I want based on a given criteria (selection box).
 
No joy so far, but probably down to my lack of development experience/ability.

Mark


Mark Rowan - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Paul,
 
Taking your "Dynamic Table with Data Source and Repeat Control" example, if you were to add a "Status" selection box, how would you restrict the displayed content to the Status selected, eg New?

Mark


Mark Rowan - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community