使用dataTable需要哪些文件
What files are required for using dataTable?
我尝试初始化DataTable,但无法初始化。
<style type="text/css" title="currentStyle">
@import "demo_page.css";
@import "demo_table.css";
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.dataTables.js"></script>
怎么了?
表格的结构是必需的吗?
是否需要数据?
<table id="example"> <thead> <tr> <th>Column 1</th> </tr> </thead> <tbody> <tr> <td>data</td> </tr> </tbody> </table>
您只需要两个文件即可初始化:
- jQuery(无论您希望如何包含它);然后
- jquery.dataTables.js(或缩小版)
如果没有合适的CSS,你的表看起来会很疯狂(添加了各种跨度来方便排序图标),但它们不是必要的。它们只是风格。
如果它没有用这两个文件和$('#myTable').dataTable()
调用(在文档就绪函数中)进行初始化,那么会发生其他事情,您需要查看JavaScript控制台,看看抛出了什么错误。
这是在他们的jsbin环境中:http://live.datatables.net/olofeg
没有CSS,只有两个JS文件,一个格式良好的表,并从文档就绪函数调用dataTable()
。
要使用数据表,您有很多选择,一种可能性是使用格式良好的(带有<thead>
和<tbody>
)HTML表来"转换"
<style type="text/css" title="currentStyle">
@import "demo_page.css";
@import "demo_table.css";
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.dataTables.js"></script>
<table id="example">
<thead>
<tr>
<th>Column 1</th>
</tr>
</thead>
<tbody>
<tr>
<td>data</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
//initialize datatables
(function($){
$('#example').dataTable();
});
</script>
您必须在javascript 中调用dataTable函数
<script type="text/javascript">
$(document).ready(function(){
$("example").dataTable();
});
</script>
我研究了一整天。据推测,jQuery被大型人数,但我找不到一个"单身"博客,上面写着要导入到您的html/jsp中的所有"最低限度"的东西利用jQuery数据表功能。。。因此,我将其编译成一个小的html页面,如下所示(这完全工作的东西,所以请从这里开始,按照自己的方式建造。)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
<script src="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.2/css/jquery.dataTables.min.css">
<script type="text/javascript">
$(document).ready(function () {
$("#companies").dataTable({
"sPaginationType": "full_numbers",
"bJQueryUI": true
});
});
</script>
</head>
<body id="dt_example">
<div id="container">
<div id="demo_jui">
<table id="companies" class="display">
<thead>
<tr>
<th>Company name</th>
<th>Address</th>
<th>Town</th>
</tr>
</thead>
<tbody>
<tr>
<th>Atlassian</th>
<th>Paramatta</th>
<th>Sydney</th>
</tr>
<tr>
<th>Oracle</th>
<th>Whitefield</th>
<th>India</th>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
相关文章:
- 如何播放部分音频文件
- 从桌面读取python文件时高亮显示代码
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 如何使用WCF服务和javascript表单post上传.doc文件
- 当包含另一个asp文件时,是否也包含所有引用的样式和脚本页面
- 如何在生成下载文件时显示加载动画
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- Javascript-如何读取json文件中的列并将其保存在Javascript数组中
- 将jsp文件下拉列表中的选定项分配给一个java变量(比如String selection)
- 正在SharePoint 2013母版页中添加JQuery移动文件
- 如何在php文件中获取$.post-ajax传递的值
- 直接下载文件,而不是从window.open(url)
- 如何在android中使用phonegap将文件从一个文件夹移动/复制到另一个文件夹
- 使用压缩的JavaScript文件(不是运行时压缩)
- 从上载的CSV文件创建DataTable
- 如何将json文件加载到datatable
- 使用dataTable需要哪些文件
- 如何排序日期和字符串在同一列在jquery插件有文件jquery. datatable .js
- DataTable不是一个函数,引用的文件被正确加载
- 从另一个js文件中的另一个函数重新加载dataTable ajax源