您现在的位置:主页 > 技术中心 > WEB编程 > JavaScript

jquery表格排序

来源:未知 责任编辑:责任编辑 发表时间:2015-09-16 20:03 点击:

1.为每个th加一个id
 
[html]
 <thead>
      <tr>
            <th align="center" id="SERIAL_NUMBER">DATAPATCHNUMBER</th>
            <th align="center" id="SA_USERNAME">SA</th>
            <th align="center" id="U_USERNAME">Raised by </th>
            <th align="center" id="U_PRIORITY">Priority</th>
            <th align="center" id="ITD_DEV_USERNAME">Developer</th>
            <th align="center" id="ITD_STATUS">Status</th>
            <th align="center" id="U_SUBMIT_DATE">Submit Date </th>
            <th align="center" id="SA_RECE_DATE">Receive Date </th>
            <th align="center">操作</th>
       </tr>
       </thead>
 
2.     Id的名字和要排序的字段保持一致,即sql语句中order by 后面的字段。
 
3.为每个th添加click事件。
 
[java]
 <pre class="css" name="code">//添加根据不同的列排序      
 [css]
 $("thead > tr >th").eq(0).click(function(){        
         var ordertype="DESC";        
        if("${v_order_type}"=="DESC"){//如果前一次是升序,那么下一次就按降序排列        
             ordertype="ASC";        
        }else{//如果前一次是降序,那么下一次就按升序排列        
             ordertype="DESC";        
        }
 #datapatchForm").attr("action","<%=path%>/datapatch/initDatapatchInf.do?             ordertype="+ordertype+"&order_field=SERIAL_NUMBER");//提交的时候传递两个参数。Ordertype(ASC,DESC)排序方式, order_field(与th的id一样)排序字段$("#datapatchForm").submit();   

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片

推荐热点

  • Gb2312转utf-8编码的方法(vbs+js)
  • 如何使用Ajax技术开发Web应用程序(1)
  • js跳转路径问题
  • JavaScript模仿桌面窗口
  • 用js检测两个线段是否相交
  • 运用JavaScript构建你的第一个Metro式应用程序(o
  • 我知道的JavaScript -- 设计模式(桥接)应用之 – 验
  • 我是如何去了解jquery的(六),案例之幻灯片轮换
  • Jquery封装幻灯片效果
?? - ?? - ÝřŝžľŘÝź - TAGąęÇŠ - RSSśŠÔÄ - ??
Copyright © 2004-2024 上海卓卓网络科技有限公司