如何对动态呈现的表进行排序? [英] How to sort a dynamically rendered table?

查看:39
本文介绍了如何对动态呈现的表进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AJAX来显示表,我需要使用JavaScript或jQuery或最好的方法在客户端对呈现的表进行排序.

I am using AJAX to display a table, I need to sort that rendered table at client side using JavaScript or jQuery or whatever is best.

我尝试使用jQuery,它在加载页面时可以正常工作,但是可以通过将html内容动态写入div并通过排序呈现的表格无法正常工作来实现.

I tried jQuery it is working fine when page is loaded but by dynamically writing html content into a div and there by sorting that rendered table is not working.

我认为问题是JavaScript在呈现时无法正常工作,我在呈现html时编写了一些脚本警报,这些标记在呈现页面时也可以正常工作.

I think the problem is JavaScript is not working while rendering, I wrote some script alert while rendering html these tags works while rendering a page.

推荐答案

通过使用tablesorter插件:

By using tablesorter plugin:

$("table").tablesorter();

重新运行每个时间表都会受到影响(即,在页面加载完成后,仅运行一次此命令是不够的)

re-running each time table is affected (i.e it will not be enought to run this command once when page loading is complete)

这篇关于如何对动态呈现的表进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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