0

I want to update datatable object by adding key=>value pair on the particular index like - below is my datatable object value. So i just want to add a key value pair under column[0]['search'] index from jquery. I tried this dataTable.columns(0).search({"Key":"value"}).draw(); but its not working.-

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

) [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

)

1 Answer 1

0

Use ajax.data option if you want to submit additional key/value pairs to the server.

For example:

$('#example').dataTable( {
  "ajax": {
    "url": "data.json",
    "data": function ( d ) {
        d.extra_search = $('#extra').val();
    }
  }
} );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.