$(document).ready(function() {
$('#maintable').DataTable( {
searching: false,
processing: true,
serverSide: true,
ordering:false,
paging:true,
autoWidth:true,
ajax: {
url: '/voter/listVoter',
type: 'POST'
},
columns: [
{data: "voterId"},
{data: "voterName"},
{data: "age"},
{data: "gender"},
{data: "precientCode"},
{data: "pollingPlace"},
{data: "isRegFinger",
render: function(data,type,full,meta){
if(data=='1'){
return "Y";
}else{
return "N";
}
} }
],
columnDefs: [{
targets: 7,//自定义列的序号,从0开始
data: "voterId", //需要引用的数据列,一般是主键
render: function(data, type, full){
return "<button id='editrow' class='btn btn-primary' type='button' onclick='showId("+data+")' ><i class='fa fa-edit'></i></button> <button id='delrow' class='btn btn-primary' type='button'><i class='fa fa-trash-o'></i></button>"
}
}
]
} );
} );
$('#maintable').DataTable( {
searching: false,
processing: true,
serverSide: true,
ordering:false,
paging:true,
autoWidth:true,
ajax: {
url: '/voter/listVoter',
type: 'POST'
},
columns: [
{data: "voterId"},
{data: "voterName"},
{data: "age"},
{data: "gender"},
{data: "precientCode"},
{data: "pollingPlace"},
{data: "isRegFinger",
render: function(data,type,full,meta){
if(data=='1'){
return "Y";
}else{
return "N";
}
} }
],
columnDefs: [{
targets: 7,//自定义列的序号,从0开始
data: "voterId", //需要引用的数据列,一般是主键
render: function(data, type, full){
return "<button id='editrow' class='btn btn-primary' type='button' onclick='showId("+data+")' ><i class='fa fa-edit'></i></button> <button id='delrow' class='btn btn-primary' type='button'><i class='fa fa-trash-o'></i></button>"
}
}
]
} );
} );
本文介绍了一个使用jQuery DataTable插件展示选民信息列表的例子。该例子中,通过AJAX请求从服务器获取选民数据,并利用DataTable插件进行展示。列表包括选民ID、姓名、年龄、性别等信息,并提供了编辑和删除按钮。
1万+

被折叠的 条评论
为什么被折叠?



