NutzCN Logo
问答 关于datatable数据展示问题
发布于 2804天前 作者 Memory 1995 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk
var datatable;
    function initDatatable() {
        datatable = $('.datatable').DataTable({
            "dom": '<"toolbar">frtip',
            "searching": false,
            "processing": false,
            "serverSide": true,
            "select": true,
            "ordering": true,
            "language": {
                "url": "${base}/assets/plugins/datatables/cn.json"
            },
            "preDrawCallback": function () {
                sublime.showLoadingbar($(".main-content"));
            },
            "drawCallback": function () {
                sublime.closeLoadingbar($(".main-content"));
            },
            "ajax": {
                "url": "${base}/platform/customer/customerstateconfig/data",
                "type": "post",
                "data": function (d) {
                }
            },
            "order": [[0, "desc"]],
            "columns": [
				{"data": "serviceId", "bSortable": true},    // 这里的serviceId 在model里,配置的一个	
                                                                                                   @One(field="serviceId")
	                                                                                            private Service_main service_main;
                                                                                                。那么fetchLink 之后,datatable中如何读取service_main中的数据
				{"data": "customerStateCode", "bSortable": true},
				{"data": "serviceStateCode", "bSortable": true},
				{"data": "serviceStateName", "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/customer/customerstateconfig/edit/' + row.id + '" data-pjax>修改</a></li>' +
                                '<li><a href="javascript:;" onclick="del(\'' + row.id + '\')">删除</a></li>' +
                                '</ul></div>';
                    },
                    "targets": 4
                }
            ]
        });
        datatable.on('click', 'tr', function () {
            $(this).toggleClass('selected');
        });
        $("#searchBtn").on('click', function () {
            datatable.ajax.reload();
        });
    }
2 回复

额,这个只能看datatable的文档了吧,后端也就返回一个json

在浏览器控制台跟踪下url,看json数据不就知道怎么取了

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