jQuery DataTable – 使用服务器数据动态绑定复选框列

在jQuery datatable中,如何在绑定服务器数据时动态绑定复选框列?

我的代码:

oTable = $("#tblPreProcess").dataTable({
            bProcessing: true,
            bLengthChange: false,
            bFilter: true,
            sAjaxSource: '@Url.Action("FetchPreprocessOrders", "Admin")',
            aoColumns: [
               { sTitle: "Order No", bSortable: false ,bSearchable: true},
                { sTitle: "Vol.Weight", bSortable: false },
                { sTitle: "Content", bSortable: false, },               
                 { sTitle: "Bag Number", bSortable: false }                               
            ]               

        });

在上面给出的代码中,如何在“订单号”列之前添加复选框列.

最佳答案 你可以这样做,如下面的代码:

    oTable = $("#tblPreProcess").dataTable({
            bProcessing: true,
            bLengthChange: false,
            bFilter: true,
            sAjaxSource: '@Url.Action("FetchPreprocessOrders", "Admin")',
            aoColumns: [
               { sTitle: "Select", bSortable: false ,
                 mRender: function (data, type, full)
                 {
                    return '<input type="checkbox" class="selector" data-id="'+ data +'">'
                 },
               { sTitle: "Order No", bSortable: false ,bSearchable: true},
               { sTitle: "Vol.Weight", bSortable: false },
               { sTitle: "Content", bSortable: false, },               
                { sTitle: "Bag Number", bSortable: false }                               
            ]               

        });
点赞