87,910
社区成员
发帖
与我相关
我的任务
分享
$(document).ready(function () {
var listData = "";
$.ajaxSetup({
async:false
});
$.ajax({
type:"post", //请求方式
url:"ajaxList.action",
dataType:"json",
async:false,
success:function (result) {
listData = eval('(' + result + ')');
}
});
alert(listData.data[0].name)
alert("111111111=" + listData)
$('#example').dataTable({
"ajax":listData,
"bInfo":true, //开关,是否显示表格的一些信息
"bJQueryUI":true,
"language":{
"lengthMenu":"每页显示 _MENU_ 条记录",
"zeroRecords":"Nothing found - sorry",
"info":"当前显示第 _PAGE_ / _PAGES_页,总数目: _MAX_",
"infoEmpty":"No records available",
"infoFiltered":"(filtered from _MAX_ total records)"
},
"columns":[
{ "data":"name" },
{ "data":"position" },
{ "data":"office" },
{ "data":"extn" },
{ "data":"start_date" },
{ "data":"salary" }
]
});
//必须重新获取对象
var table = $('#example').DataTable();
// Apply the search
// $('#example tbody').on( 'click', 'tr', function () {
// $(this).toggleClass('selected');
// } ); 多选
//选中某一行并获得对应的值
$('#example tbody').on('mousedown', 'tr', function () {
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
}
else {
table.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
}
});
$('#button').click(function () {
alert(table.rows('.selected').data()[0].name);
});
var imageMenuData = [
[
{
text:"编辑",
func:function () {
}
}
] ,
[
{
text:"删除",
func:function () {
}
}
],
[
{
text:"失效",
func:function () {
}
}
],
[
{
text:"生效",
func:function () {
}
}
]
];
$("#example tbody").smartMenu(imageMenuData, null, "70px");
});