標籤:style io os ar java for sp 資料 on
view
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>111</title>
<link href="~/Content/jquery.dataTables.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.11.1.js"></script>
<script src="~/Scripts/jquery.dataTables.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(‘#myDataTable‘).dataTable({
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": "/User/GetAllUserDtoHandler",
"aoColumns": [{
"bVisible": true,
"mData": "UserName",
"aTargets": [0]
}, {
"bVisible": true,
"mData": "RealName",
"aTargets": [1]
}, {
"bVisible": true,
"mData": "RoleName",
"aTargets": [2]
}, {
"bVisible": true,
"mData": "DeptName",
"aTargets": [3]
}, {
"bVisible": true,
"mData": "CompanyName",
"aTargets": [4]
}, {
"bVisible": true,
"mData": "Address",
"aTargets": [5]
}, {
"bVisible": true,
"mData": "MobilePhone",
"aTargets": [6]
}],
"aoColumnDefs": [{
sDefaultContent: ‘‘,
aTargets: [‘_all‘]
}],
"oLanguage": {
"sProcessing": "正在載入中......",
"sLengthMenu": "每頁顯示 _MENU_ 條記錄",
"sZeroRecords": "沒有資料!",
"sEmptyTable": "表中無資料存在!",
"sInfo": "當前顯示 _START_ 到 _END_ 條,共 _TOTAL_ 條記錄",
"sInfoEmpty": "顯示0到0條記錄",
"sInfoFiltered": "資料表中共為 _MAX_ 條記錄",
"oPaginate": {
"sFirst": "首頁",
"sPrevious": "上一頁",
"sNext": "下一頁",
"sLast": "末頁"
}
}
});
});
</script>
</head>
<body>
<table id="myDataTable" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>
使用者名稱
</th>
<th>
真實姓名
</th>
<th>
角色
</th>
<th>
所屬部門
</th>
<th>
所屬單位
</th>
<th>
地址
</th>
<th>
電話號碼
</th>
</tr>
</thead>
<tbody></tbody>
</table>
</body>
</html>
controller
public JsonResult GetAllUserDtoHandler(DataTableParameter param)
{
using (ChannelFactory<IUserService> channelFactory = new ChannelFactory<IUserService>("userService"))
{
IUserService proxy = channelFactory.CreateChannel();
var userDtos = proxy.GetAllUserDto(param.iDisplayStart, param.iDisplayLength);
if (userDtos.Count > 0)
{
var list = new List<object>();
foreach (UserDto u in userDtos)
{
list.Add(new
{
u.UserName,
u.RealName,
u.RoleName,
u.DeptName,
u.CompanyName,
u.Address,
u.MobilePhone
});
}
return Json(new
{
sEcho = param.sEcho,
iTotalRecords = userDtos.Count,
iTotalDisplayRecords = userDtos.Count,
aaData = list
}, JsonRequestBehavior.AllowGet);
}
}
return null;
}
WCF後台略
jquery datatables+MVC+WCF