【问题标题】:mRenderProp not returning the buttonmRenderProp 不返回按钮
【发布时间】:2014-11-29 13:41:12
【问题描述】:

我正在构建一个在数据表服务器端处理上运行的 CRUD 应用程序,我设法动态生成表,但是当我尝试创建一个可单击的按钮以查看更多信息时,它失败并且只显示唯一的标识符。 请告知我在 mRenderProp 上做错了什么? 下面是我生成数据表的脚本:

<script type="text/javascript">
    $(document).ready(function () {

        Draw();
        function Draw() {

            $('#example_ta').dataTable({
                "bJQueryUI": true,
                "bautoWidth": false,
                "aoColumns": [
                    {"sTitle": "Delivery Date", "mDataProp": "delivery_date"},
                    {"sTitle": "Delivery No.", "mDataProp": "delivery_no"},
                    {"sTitle": "Unit Code", "mDataProp": "unit_code"},
                    {"sTitle": "Driver Code.", "mDataProp": "driver_code"},
                    {"sTitle": "Zone Name.", "mDataProp": "zone_name"},
                    {"sTitle": "Zone Rate", "mDataProp": "zone_rate"},
                    {"sTitle": "Tonnage", "mDataProp": "tonnage"},
                    {"sTitle": "Standard Tonne", "mDataProp": "standard_tonne"},
                    {"sTitle": "View", "mDataProp": "delivery_id",
                        "mRenderProp": function (data, type, full) {
                            return '<button class="show-data btn btn-small btn-primary" id = ' + data + ' >View</button>';
                        }
                    },
                ],
                "bDeferRender": true,
                "bProcessing": true,
                "bDestroy": true,
                "bLengthChange": true,
                "iDisplayLength": 10,
                "sAjaxDataProp": "",
                "sAjaxSource": '<?php echo site_url() . "admin_profile/getDeliveries/"; ?>',
                "aaSorting": [[3, "asc"]]
            });
        }


    });

</script>
<table class="example_ta" id="example_ta">
    <thead>
        <tr>

        </tr>
    </thead>

    <tbody>
        <tr></tr>
    </tbody>

</table>

【问题讨论】:

    标签: php jquery json codeigniter jquery-datatables


    【解决方案1】:

    这只是mRender 而不是mRenderProp - 请参阅docs

    {"sTitle": "View", "mDataProp": "delivery_id",
                            "mRender": function (data, type, full) {
                                return '<button class="show-data btn btn-small btn-primary" id = ' + data + ' >View</button>';
                            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-18
      • 2016-09-08
      • 1970-01-01
      • 1970-01-01
      • 2020-05-18
      相关资源
      最近更新 更多