NutzCN Logo
问答 问一个关于datatable的问题
发布于 2783天前 作者 liumaobudao 1792 次浏览 复制 上一个帖子 下一个帖子
标签:

"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
// Bold the grade for all ‘A‘ grade browsers
console.log(aData.opStatus);
if ( aData.opStatus == "已提交" )
{
console.log(nRow);
// var id = $('td', nRow).eq(-1).text();
$('td:eq(17)', nRow).html( '' +
' ' +
'${msg["globals.button.detail"]}' +
'');
//$('td:eq(5)', nRow).Format("yyyy-MM-dd");
//.style.display=="none";
}
}

7 回复
 "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
                // Bold the grade for all ‘A‘ grade browsers
                console.log(aData.opStatus);
                if ( aData.opStatus == "已提交" )
                {
                    console.log(nRow);

                   // var id = $('td', nRow).eq(-1).text();
                    $('td:eq(17)', nRow).html( '<div class="btn-group"><button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">' +
                        ' <i class="ti-settings"></i> <span class="ti-angle-down"></span></button><ul class="dropdown-menu" role="menu">' +
                        '<li><a href="${base}/platform/jxfzxt/baseinfo/detail/'+(这里的id如何才能获取到页面上是隐藏的)+'" data-toggle="modal" data-target="#dialogDetail">${msg["globals.button.detail"]}</a></li>' +
                        '</ul></div>');
                    //$('td:eq(5)', nRow).Format("yyyy-MM-dd");
                    //.style.display=="none";
                }
            }

id从哪里来

@wendal

 var datatable;
    function initDatatable() {
        datatable = $('.datatable').DataTable({
            "dom": '<"toolbar">frtip',
            "searching":false,
            "processing": false,
            "serverSide": true,
            "select": true,
            "pageLength":1000,
            "scrollY":  document.body.clientHeight-250,
            "ordering": true,
            "language": {
                "url": "${base}/assets/plugins/datatables/${lang}.json"
            },
            "preDrawCallback": function () {
                sublime.showLoadingbar($(".main-content"));
            },
            "drawCallback": function () {
                sublime.closeLoadingbar($(".main-content"));
            },
            "mRender": function ( data, type, full ) {
                return '<input type="text" type="hidden" class="userName" value="'+full+'"/>';
            },
            "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
                // Bold the grade for all ‘A‘ grade browsers
                console.log(aData.opStatus);
                if ( aData.opStatus == "已提交" )
                {
                    console.log(nRow);

                   // $('td:eq(4)', nRow).html( ‘<b>A</b>‘ );
                  //  $('#editdom').html( 'awdawd' );
                    var id = $('td', nRow).eq(-1).text();
                    $('td:eq(17)', nRow).html( '<div class="btn-group"><button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">' +
                        ' <i class="ti-settings"></i> <span class="ti-angle-down"></span></button><ul class="dropdown-menu" role="menu">' +
                        '<li><a href="${base}/platform/jxfzxt/baseinfo/detail/'+nRow.row+'" data-toggle="modal" data-target="#dialogDetail">${msg["globals.button.detail"]}</a></li>' +
                        '</ul></div>');
                    //$('td:eq(5)', nRow).Format("yyyy-MM-dd");
                    //.style.display=="none";
                }
            },
            "ajax": {
                "url": "${base}/platform/jxfzxt/baseinfo/data",
                "type": "post",
                "data": function (d) {
                    d.teaId = $('#teaId').val();
                    d.teaName = $('#teaName').val();
                    d.office = $('#office').val();
                }
            },
            "order": [[0, "desc"]],
            "columns": [
                    {"data": "id"},
                    {"data": "teaId", "bSortable": true},
                    {"data": "teaName", "bSortable": true},
                    {"data": "office", "bSortable": true},
                    {"data": "teaSex", "bSortable": true},
                    {"data": "teaBirthday", "bSortable": true},
                    {"data": "teaMz", "bSortable": true},
                    {"data": "teaSsjys", "bSortable": true},
                    {"data": "teaXl", "bSortable": true},
                    {"data": "teaXw", "bSortable": true},
                    {"data": "teaBytime", "bSortable": true},
                    {"data": "teaBysch", "bSortable": true},
                    {"data": "teaWorktime", "bSortable": true},
                    {"data": "teaZyjszw", "bSortable": true},
                    {"data": "teaNwtime", "bSortable": true},
                    {"data": "teaPropro", "bSortable": true},
                    {"data": "teaTel", "bSortable": true},
                    {"data": "teaEmail", "bSortable": true},
                {"data": "opStatus", "bSortable": true},
            ],
            "columnDefs": [
                {
                    "render": function (data, type, row) {
                        return '<div class="btn-group"><button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">' +
                                ' <i class="ti-settings"></i> <span class="ti-angle-down"></span></button><ul class="dropdown-menu" role="menu">' +
                                '<li><a href="${base}/platform/jxfzxt/baseinfo/detail/' + row.id + '" data-toggle="modal" data-target="#dialogDetail">${msg["globals.button.detail"]}</a></li>' +
                                '<%if(@shiro.hasPermission("platform.jxfzxt.baseinfo.edit")){%><li id="editdom"><a href="${base}/platform/jxfzxt/baseinfo/edit/' + row.id + '" data-pjax>${msg["globals.button.update"]}</a></li><%}%>' +
                                '<li class="divider"></li>' +
                                '<%if(@shiro.hasPermission("platform.jxfzxt.baseinfo.delete")){%><li><a href="javascript:;" onclick="del(\'' + row.id + '\')">${msg["globals.button.delete"]}</a></li><%}%>' +
                                '</ul></div>';
                    },
                    "targets": 17+1
                },
                {
                    "targets": [0], //隐藏第六列,从第0列开始
                    "visible": false
                }
            ]
        });
        datatable.on('click', 'tr', function () {
            $(this).toggleClass('selected');
        });
        $("#searchBtn").on('click', function () {
            datatable.ajax.reload();
        });
    }

依然没搞懂你想问啥

添加回复
请先登陆
回到顶部