【问题标题】:I failed to refresh data in yajra/laravel-datatables-oracle with draw method我无法使用 draw 方法刷新 yajra/laravel-datatables-oracle 中的数据
【发布时间】:2020-09-19 07:46:08
【问题描述】:

在 laravel 6 应用程序中,我使用“yajra/laravel-datatables-oracle”:“^9.4”,我需要选择 1 行并在服务器上运行 ajax 请求以删除该行 我尝试使用 draw() 方法刷新表格,但它不起作用。

在我的刀片文件中:

@push('scripts')

    var oTable;
    $(document).ready(function () {

            oTable = $('#my_tasks_data').DataTable({
                processing: true,
                serverSide: false,
                info: false,
                order: [],
            });
            $('div.dataTables_length select').select2({
                theme: "bootstrap"
            });

            ...
        function taskComplete(rowId) {
            $.ajax({
                url: 'tasks/' + rowId + '/complete',
                type: "post",
                dataType: 'json',
                data: {'_token': '{{csrf_token()}}'},
                success: function (data) {
                    console.log('taskComplete success data::')
                    console.log(data)
                    console.log('oTable::')
                    console.log(oTable)   
                    oTable.draw();  // THat does not work

                    alert( 'AFTER::' )
                },
                error: function (xhr) {
                    console.error(xhr)
                }
            });

        }

我检查了 oTable var 并看到:https://prnt.sc/ujyp14 它看起来像有效的 Table 对象

为什么它不起作用以及如何解决?

谢谢!

【问题讨论】:

    标签: javascript laravel laravel-datatables


    【解决方案1】:

    我发现将 serverSide 属性设置为 true 的决定

    oTable = $('#my_tasks_data').DataTable({
        processing: true,
        serverSide: true,
    

    在那个方法之后 oTable.draw() 工作正常

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-23
      • 2021-08-02
      • 2021-07-31
      • 2021-05-27
      • 2016-10-05
      • 2018-11-05
      • 2020-06-12
      相关资源
      最近更新 更多