html代码
queue ID | 发送人 | 接收人 | 发送时间 | 主题 | 邮件大小 | 发送状态 | 失败原因 | 邮件编码 | 操作 |
---|
js代码
$(document).ready(function() { $('.table-sort').DataTable( { //"aaSorting": [[ 4, "desc" ]],//默认第几个排序 "processing": true, "serverSide": true, "bAutoWidth": true, //自动宽度 "iDisplayLength": 4, //显示条数 "bFilter": true, //是否启用过滤 "bPaginate": true, //翻页功能 "bLengthChange": true, //改变每页显示数量 "bSort": false, //排序功能 "bStateSave": false,//状态保存 "sPaginationType": "full_numbers", "ajax" : "/testdata", /* "ajax": { "url" : "/testdata", "type" : "POST", }, */ "columnDefs": [{ "orderable": false,//禁用排序 "targets": [0,1,2,3,5,6,7,8,9,10] //指定的列 }] } );} );
server端flask代码
@app.route('/testdata',methods = ['GET', 'POST'])def testdata(): pagesize = int(request.args.get('length')) start = int(request.args.get('start')) search = request.args.get('search[value]') message =[] if search: message_list = Maillog.query.filter(or_(Maillog.mailsubject.like("%%%s%%" % search),Maillog.reason.like("%%%s%%" % search))).order_by(Maillog.mailtime.desc()).offset(start).limit(pagesize).all() else: message_list = Maillog.query.order_by(Maillog.mailtime.desc()).offset(start).limit(size).all() message_num = len(Maillog.query.order_by(Maillog.mailtime.desc()).all()) for x,y in enumerate(message_list): checkl = '' % y.queueid options = '' %y.queueid messagey=[checkl,y.queueid,y.sender,y.receive,y.mailtime,y.mailsubject,y.mailsize,y.mailstatus,y.reason,y.codechar,options] message.append(messagey) messagedata= { "recordsTotal": message_num, "recordsFiltered": message_num, "data": message} return json.dumps(messagedata)