【问题标题】:How to update datatable object from jquery如何从 jquery 更新数据表对象
【发布时间】:2018-03-05 12:07:20
【问题描述】:

我想通过在特定索引上添加 key=>value 对来更新数据表对象,例如 - 下面是我的数据表对象值。所以我只想在 jquery 的 column[0]['search'] 索引下添加一个键值对。我试过这个 dataTable.columns(0).search({"Key":"value"}).draw();但它不起作用。-

数组
(
    [画] => 2
    [列] => 数组
        (
            [0] => 数组
                (
                    [数据] => 0
                    [名称] =>
                    [可搜索] => 真
                    [可订购] => 真
                    [搜索] => 数组
                        (
                            [价值] =>
                            [正则表达式] => 假
                        )

            )

        [1] => Array
            (
                [data] => 1
                [name] => 
                [searchable] => true
                [orderable] => true
                [search] => Array
                    (
                        [value] => 
                        [regex] => false
                    )

            )

        [2] => Array
            (
                [data] => 2
                [name] => 
                [searchable] => true
                [orderable] => true
                [search] => Array
                    (
                        [value] => 
                        [regex] => false
                    )

            )

        [3] => Array
            (
                [data] => 3
                [name] => 
                [searchable] => true
                [orderable] => true
                [search] => Array
                    (
                        [value] => 
                        [regex] => false
                    )

            )

        [4] => Array
            (
                [data] => 4
                [name] => 
                [searchable] => true
                [orderable] => true
                [search] => Array
                    (
                        [value] => 
                        [regex] => false
                    )

            )

        [5] => Array
            (
                [data] => 5
                [name] => 
                [searchable] => true
                [orderable] => true
                [search] => Array
                    (
                        [value] => [object Object]
                        [regex] => false
                    )

            )

        [6] => Array
            (
                [data] => 6
                [name] => 
                [searchable] => true
                [orderable] => true
                [search] => Array
                    (
                        [value] => 
                        [regex] => false
                    )

            )

        [7] => Array
            (
                [data] => 7
                [name] => 
                [searchable] => true
                [orderable] => true
                [search] => Array
                    (
                        [value] => 
                        [regex] => false
                    )

            )

        [8] => Array
            (
                [data] => 8
                [name] => 
                [searchable] => true
                [orderable] => true
                [search] => Array
                    (
                        [value] => 
                        [regex] => false
                    )

            )

        [9] => Array
            (
                [data] => 9
                [name] => 
                [searchable] => true
                [orderable] => true
                [search] => Array
                    (
                        [value] => 
                        [regex] => false
                    )

            )

    )

[order] => Array
    (
        [0] => Array
            (
                [column] => 0
                [dir] => desc
            )

    )

[start] => 0
[length] => 10
[search] => Array
    (
        [value] => 
        [regex] => false
    )

[type] => mytask

)

【问题讨论】:

    标签: jquery datatables


    【解决方案1】:

    如果您想向服务器提交额外的键/值对,请使用ajax.data 选项。

    例如:

    $('#example').dataTable( {
      "ajax": {
        "url": "data.json",
        "data": function ( d ) {
            d.extra_search = $('#extra').val();
        }
      }
    } );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-21
      • 1970-01-01
      相关资源
      最近更新 更多