jquery datatables+MVC+WCF

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.