Hello friends,
maybe someone can forward me a tip.
I am sorting dynamically a table by the event onclick on a tableheader using
Javascript.
My problem consist, that i use the first row as a invisible row, to store
default values if there are, which i clone if a user want generate a new row in
this table.
After sorting the table, this invisible row get sort, so my display of this
table with alternating the rows with two colors get wrong, because the
invisible are at the bottom or even inside the table. At default i sort by <col
name=rowid> so the first invisble row are always at the top.
Is there a possibility to sort dynamically the table without the first row with
the attribut display=none by DOM or innerHTML ? How must i configure my xsl or
xml to get it work ?
Above the essential snippets:
Thanks,
Hans Braumüller
Systementwickler Web-Design
Hanse Orga AG
XML:
...
<tabelle rows="6" cols="6">
<row name="row-0" display="0">
<col name="rowid"/>
<col name="kennung"/>
<col name="date"/>
<col name="betrag"/>
<col name="list1"/>
<col name="checkBox"/>
</row>
<row name="row-1">
<col name="rowid"/>
<col name="kennung">zz</col>
<col name="date">01.01.2001</col>
<col name="betrag">4711</col>
<col name="list1">USD</col>
<col name="checkBox">0</col>
</row>
<row name="row-2">
<col name="rowid"/>
<col name="kennung">w</col>
<col name="date">12.12.2002</col>
<col name="betrag">47122</col>
<col name="list1">EUR</col>
<col name="checkBox">0</col>
</row>
...
</tabelle>
XSL:
...
<xsl:apply-templates select="row">
<xsl:sort select="col[(_at_)name='rowid']" order="ascending"
data-type="number" />
</xsl:apply-templates>
...
...
<xsl:template match="row">
<xsl:variable name="row" select="count(preceding::row) " />
<tr onmouseover="lightTableRow(this)" onclick="selectRow(this.id)">
...
<xsl:if test="@display='0'">
<xsl:attribute name="style">display:none</xsl:attribute>
</xsl:if>
...
<xsl:apply-templates select="col" >
<xsl:with-param name="row" select="$row"/>
</xsl:apply-templates>
</tr>
</xsl:template>
JAVASCRIPT:
xmlDoc = document.XMLDocument;
xslDoc = document.XSLDocument;
sortby = xslDoc.selectSingleNode("//xsl:sort/@select");
datatype = xslDoc.selectSingleNode("//xsl:sort/@data-type");
orderby = xslDoc.selectSingleNode("//xsl:sort/@order");
function sort(field,format, tableId){
...
output.innerHTML = xmlDoc.documentElement.transformNode(xslDoc);
...
}
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list