跳转到主内容
趣航编程网 - 趣学编程,启航技术之路!

jQuery+Ajax实现表格数据标题排序

这次给大家带来jQuery+Ajax实现表格数据标题排序,jQuery+Ajax实现表格数据标题排序的 注意事项 有哪些,下面就是实战案例,一起来看一下。 表格大家都十分熟悉,如今的CSS也使得表格的布局越来越光彩耀人。但是,无论如何,都掩饰不了那些包装下的死板。 那么如何让那些死板的数据 更具有可读性、可用性,能够让我们那些数据在“动”呢? 下面我们使用jquery+ajax 来为表格注入些活力。主要实现的目的就是:将表格的列标题转化为按钮,点击不同的列标题,便按相应的列对数据进行排序。比如学生信息表,我点击“生日”列,这张表便按生日排序将结果呈现在我们面前。使用ajax来调用本页也避免了刷新页面所带来的折磨。 下面我给出最基本的jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> My JSP 'sorttable.jsp' starting page
Title Author PublishDate Price
/images/javascript.jpg" width="40" height="50" alt="JavaScript" /> JavaScript Douglas Crockford May 2008 $31.02
/images/Ajax.jpg" width="40" height="50" alt="AJAX and PHP:Building Responsive Web Applications" /> AJAX and PHP:Building Responsive Web Applications Cristian Darie,Mihak Bucica Mar 2006 $31.02
/images/Learning.jpg" width="40" height="50" alt="Learning Mambo" /> Learning Mambo Douglas Paterson Mar 2006 $31.02
/images/Think.jpg" width="40" height="50" alt="Thinking in java" /> Thinking in java Bruce Eckel Feb 2006 $33.02
/images/jQuery.jpg" width="40" height="50" alt="jQuery in Action, Second Edition" /> jQuery in Action, Second Edition Bear Bibeault / Yehuda Katz Apr 2010 $35.02
第一步:为表格添加奇偶行交替背景
第二步:按字母排序 实现基于表格的Title列进行排序
Title
为Title定义了一个sort-alpha类
最后 当你点击Title时 最终效果: 相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章! 推荐阅读: jquery实现表格排序+实时搜索功能 sortElements实现table排序步骤详解 jquery动态操作表格行的方法(附代码)

相关文章