码迷,mamicode.com
首页 > 其他好文 > 详细

datable

时间:2018-11-16 18:49:27      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:cli   bottom   stripe   set   编号   die   背景颜色   添加   orm   

     $("#table_d").append("<table id=‘dmglTable‘ class=‘table table-striped table-hover table-bordered dataTable no-footer dtr-inline‘></table>");
        var zwkmzdTable = $("#dmglTable").dataTable({
            serverSide: true,
            responsive: true,
            processing:true,
            autoWidth: true,//自动计算列宽
            deferRender: true,//设置延迟渲染,提高效率用
            draw:false,
            order: [ 1, ‘asc‘ ],
            ajax: {
                url: "dmgl/getDmglInfoData",
                type: "POST",
                data : function(d) {  
                    var sentJson = GET_SENT_JSON(d);
                    
                    //追加数据 sentJson.name=22
                    return sentJson;
                },
                error: function (e) {
                    ALERT_ERROR(zwkmzdTable,e);
                },
            },
            lengthMenu: PAGELENGTH,
            "language": LANGUAGESETTING,
            oLanguage: {//多语言配置
                "sSearchPlaceholder": "科目编号、名称",//搜索框内占位符
                "sSearch": "检索:",//搜索框前的字体
                "sProcessing": "正在加载中......",
                "sLengthMenu": "每页显示 _MENU_ 条记录",
                "sZeroRecords": "对不起,查询不到相关数据!",
                "sEmptyTable": "表中无数据存在!",
                "sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_ 条记录",
                "sInfoEmpty": "没有记录可以显示",
                "sInfoFiltered": "数据表中共为 _MAX_ 条记录",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上一页",
                    "sNext": "下一页",
                    "sLast": "末页"
                }
            },
            columnDefs : [
                { "targets": 0 ,"name":"kmbh","title": "","width": "2%"},
                { "targets": 1 ,"name":"kmbh","title": "科目编号","width": "10%"},
                { "targets": 2 ,"name":"kmmc","title": "科目名称" ,"width": "15%"},
                { "targets": 3 ,"name":"kmsx","title": "科目属性" ,"width": "5%"}
            ],
            columns: [
                {
                    "className":      ‘details-control‘,
                    "orderable":      false,
                    "data":           null,
                    "defaultContent": ‘‘
                },
                { data: ‘kmbh‘},
                { data: ‘kmmc‘},
                { ‘data‘: function(value){
                      var kmsx = value.kmsx;
                      if (kmsx == 1) {
                          return ‘资产‘;
                      } else if(kmsx == 2){
                          return ‘负债‘;
                      } else if(kmsx == 3){
                          return ‘净资产‘;
                      } else if(kmsx == 4){
                          return ‘收入‘;
                      } else if(kmsx == 5){
                          return ‘支出‘;
                      } else if(kmsx == 6){
                          return ‘预算‘;
                      }else{
                          return ‘ ‘;
                      }
                  }
         },
] }); $(‘#dmglTable tbody tr‘).die().live(‘click‘, function() { var tr = $(this).closest(‘tr‘) var row = $(‘#dmglTable‘).DataTable().row(this) if ( row.child.isShown() ) { row.child.hide(); tr.removeClass(‘shown‘); // tr.children("td.details-control").children("i").attr(‘class‘,‘fa fa-plus-square‘); } else { row.child( format(row.data()) ).show(); tr.next().children("td").css({"padding": "0px"}); tr.addClass(‘shown‘); // tr.children("td.details-control").children("i").attr(‘class‘,‘fa fa-minus-square‘); } }); //鼠标移动添加背景颜色 mouseEvent("dmglTable"); }; function format (d) { var wbhs; var bmhs; var xmhs; return ‘<table class="table table-striped table-hover table-bordered no-footer1 dtr-inline" style="margin-bottom: 0px">‘+ ‘</tr>‘+ ‘<td style="border: 0px solid #ddd;text-align:right;width: 10%">外币核算:</td>‘+ ‘<td style="border: 0px solid #ddd;text-align:left;width: 8%">‘+wbhs+‘</td>‘+ ‘<td style="border: 0px solid #ddd;text-align:right;width: 8%">外币编号:</td>‘+ ‘<td style="border: 0px solid #ddd;text-align:left;width: 8%">‘+wbbh+‘</td>‘+ ‘<td style="border: 0px solid #ddd;text-align:right;width: 8%">部门核算:</td>‘+ ‘<td style="border: 0px solid #ddd;text-align:left;width: 8%">‘+bmhs+‘</td>‘+ ‘</tr>‘+ ‘</table>‘; }

 

datable

标签:cli   bottom   stripe   set   编号   die   背景颜色   添加   orm   

原文地址:https://www.cnblogs.com/sunBinary/p/9970893.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!