87,910
社区成员
发帖
与我相关
我的任务
分享
$(function () {
var oTable;
$(document).ready(function() {
oTable = initTable();//初始化表格
});
function initTable() {
$("#example1").DataTable({
"processing" : true,
"serverSide" : true,
"bFilter" : true, //是否启动过滤、搜索功能
"bSort" : true,
"iDisplayLength" : 10,
"sAjaxSource" : "{:U('Test/testData')}",
'bPaginate' : true,//分页
"bDestory" : true,//??
"bRetrieve" : true,//??
"aLengthMenu" : [ [ 2, 5, 10, -1 ],
[ 2, 5, 10, "All" ] ],
"bStateSave" : true,
"oLanguage": { //国际化配置
"sProcessing" : "正在获取数据,请稍后...",
"sLengthMenu" : "显示 _MENU_ 条项结果",
"sZeroRecords" : "没有您要搜索的内容",
"sInfo" : "显示第 _START_ 至 _END_ 项结果 ,共 _TOTAL_ 项",
"sInfoEmpty" : "记录数为0",
"sInfoFiltered" : "(全部记录数 _MAX_ 条)",
"sInfoPostFix" : "",
"sSearch" : "搜索",
"oPaginate": {
"sFirst" : "第一页",
"sPrevious" : "上一页",
"sNext" : "下一页",
"sLast" : "最后一页"
}
},
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0 ] }] ,
"aoColumns" : [
{
"mDataProp" : "id"
},
{
"mDataProp" : "name"
},
{
"mDataProp" : "email"
},
{
"mDataProp" : "id",
"fnCreatedCell" : function(nTd, sData, oData, iRow, iCol) {
$(nTd)
.html("<a class='btn btn-info' href='edit?id="+sData+"'>修改</a> ")
.append("<a class='btn btn-success' href='Info?id="+sData+"'>管理信息</a> ")
}
}, ],
"fnInitComplete" : function(oSettings, json) {
$(
'<a href="{:U('Test/testAdd')}" class="btn btn-primary">添加</a>').appendTo(
$('.myBtnBox'));
},
});
}
});
<div class="box">
<div class="box-header">
<div class="span6 myBtnBox"></div>
</div>
<!-- <form method="post"> -->
<!--<label>名称:</label><input type="text" class="column_filter_name form-control input-inline" id="col1_filter" data-column="1" value="t"> -->
<input type="text" id="name" name="name">
<input type="text" id="email" name="email">
<button type="sumbit" name="btnType" id="btnType">查询</button>
<!-- </form> -->
<!-- /.box-header -->
<div class="box-body">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th width="50">ID</th>
<th width="100">名称</th>
<th width="100">邮箱</th>
<th width="150" align="center">管理</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<!-- /.box-body -->
</div>
//向服务器传额外的参数
"fnServerParams": function (data) {
data.push({"name": "username", "value": $.trim($('#username').val())});
data.push({"name": "quanxian", "value": $('#quanxian').val()});
data.push({"name": "phone", "value": $('#phone').val()});
data.push({"name": "money", "value": $('#money').val()});
data.push({"name": "state", "value": $('#state').val()});
data.push({"name": "checkoutDateStart", "value": $('#checkoutDateStart').val()});
data.push({"name": "checkoutDateEnd", "value": $('#checkoutDateEnd').val()});
}
};