根据列点击次数对html表内容进行排序 [英] Sort the html table contents based on column clicks

查看:76
本文介绍了根据列点击次数对html表内容进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<<pre lang="xml"><pre lang="xml">?xml version="1.0" encoding="UTF-8"?>
<ExperimentalSets>
  <ExperimentalSet GUID="Set01">
    <Identity>
      <Name>The First Experimental Set</Name>
      <Description/>
    </Identity>
    <Experiments OrderBy="Value">
      <Experiment GUID="Expt0009" DesignIndex="15" RunIndex="12">11</Experiment>
      <Experiment GUID="Expt0014" DesignIndex="14" RunIndex="7" >25</Experiment>
      <Experiment GUID="Expt0013" DesignIndex="13" RunIndex="3" >37</Experiment>
      <Experiment GUID="Expt0012" DesignIndex="12" RunIndex="1" >41</Experiment>
      <Experiment GUID="Expt0011" DesignIndex="11" RunIndex="5" >54</Experiment>
      <Experiment GUID="Expt0010" DesignIndex="10" RunIndex="9" >69</Experiment>
    </Experiments>
  </ExperimentalSet>
  <ExperimentalSet GUID="Set02">
    <Identity>
      <Name>The Second Experimental Set</Name>
      <Description/>
    </Identity>
    <Experiments OrderBy="Run Index">
      <Experiment GUID="Expt1012" DesignIndex="12" RunIndex="1" >1004</Experiment>
      <Experiment GUID="Expt1005" DesignIndex="5"  RunIndex="2" >1102</Experiment>
      <Experiment GUID="Expt1013" DesignIndex="13" RunIndex="3" >1324</Experiment>
      <Experiment GUID="Expt1007" DesignIndex="7"  RunIndex="4" >1921</Experiment>
      <Experiment GUID="Expt1011" DesignIndex="11" RunIndex="5" >1245</Experiment>
    </Experiments>
  </ExperimentalSet>
</ExperimentalSets>

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
    <xsl:output method="html" indent="yes"/>
    <xsl:template match="ExperimentalSets">
      <html>
        <body>
          <script type="text/JavaScript">
            function parsingAttributes(control)
            {
            var ctr= document.getElementById(control.text);
            ctr.style.display=''block'';
            }
            function sortByNumber(divid,txt)
            {

            }
          </script>
          <xsl:apply-templates select="ExperimentalSet">
           </xsl:apply-templates>
        </body>
      </html>
    </xsl:template>
  <xsl:template match ="ExperimentalSet">
    <xsl:variable name="NodeName">
      <xsl:value-of select="Identity/Name"/>
    </xsl:variable>
  <a href="#" onclick="parsingAttributes(this)">
    <xsl:value-of select="Identity/Name"/>
  </a>
    <div id="{$NodeName}" style="display:none">
      <table border="4">
        <tr>
          <th onclick="sortByNumber(''{$NodeName}'',this)">Number</th>
          <th>GUID</th>
          <th>Design Index</th>
          <th>Run Index</th>
        </tr>

        <xsl:for-each select ="Experiments/Experiment">
          <tr>
            <td>
              <xsl:value-of select ="text()"/>
            </td>
            <td>
              <xsl:value-of select ="@GUID"/>
            </td>
            <td>
              <xsl:value-of select ="@DesignIndex"/>
            </td>
            <td>
              <xsl:value-of select ="@RunIndex"/>
            </td>
          </tr>
        </xsl:for-each>
       </table>
    </div>

  <br />
  </xsl:template>
</xsl:stylesheet


>

相关的xsl文件是上面显示的文件.
需要基于用户提供的列单击来对html表内容进行排序.

必须根据用户的点击动态地完成此操作.
即,如果用户单击编号",则将根据编号对内容进行排序;如果用户单击设计索引",则必须按设计索引对数据进行排序.

简而言之,我们如何基于xslt中的onclick等事件对数据进行动态排序.


请发表您的建议.


>

the related xsl file is the one shown above.
The need is to sort the html table contents based on the column clicks provided by the user.

This has to be done dynamically based on the user clicks.
i.e. if the user clicks on Number the contents are to be sorted based on number,if the user clicks on Design Index the data has to be sorted by design Index..

In short how do we sort the data dynamically based on events like the onclick in xslt.


Kindly post in your suggestions.

推荐答案

NodeName}"style =" display:none> < table border ="4"> < tr> < th onclick ="sortByNumber(''{
NodeName}" style="display:none"> <table border="4"> <tr> <th onclick="sortByNumber(''{


NodeName}'',this)"> Number</th> < GUID</th> <设计索引</th> <运行指数</th> </tr> < xsl:for-each选择=实验/实验"> < tr> < td> < xsl:value-of select ="text()"/> </td> < td> < xsl:value-of select ="@ GUID"/> </td> < td> < xsl:value-of select ="@ DesignIndex"/> </td> < td> < xsl:value-of select ="@ RunIndex"/> </td> </tr> </xsl:for-each> </table> </div> < br/> </xsl:template> </xsl:stylesheet
NodeName}'',this)">Number</th> <th>GUID</th> <th>Design Index</th> <th>Run Index</th> </tr> <xsl:for-each select ="Experiments/Experiment"> <tr> <td> <xsl:value-of select ="text()"/> </td> <td> <xsl:value-of select ="@GUID"/> </td> <td> <xsl:value-of select ="@DesignIndex"/> </td> <td> <xsl:value-of select ="@RunIndex"/> </td> </tr> </xsl:for-each> </table> </div> <br /> </xsl:template> </xsl:stylesheet


>

相关的xsl文件是上面显示的文件.
需要基于用户提供的列单击来对html表内容进行排序.

必须根据用户的点击动态地完成此操作.
即,如果用户单击编号",则将根据编号对内容进行排序;如果用户单击设计索引",则必须按设计索引对数据进行排序.

简而言之,我们如何基于xslt中的onclick等事件对数据进行动态排序.


请发表您的建议.


>

the related xsl file is the one shown above.
The need is to sort the html table contents based on the column clicks provided by the user.

This has to be done dynamically based on the user clicks.
i.e. if the user clicks on Number the contents are to be sorted based on number,if the user clicks on Design Index the data has to be sorted by design Index..

In short how do we sort the data dynamically based on events like the onclick in xslt.


Kindly post in your suggestions.


您好,
请参考以下链接
使所有表都可排序 [
Hi,
Please refer following link
Make all your tables sortable[^]

Thanks,
Imdadhusen


这篇关于根据列点击次数对html表内容进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆