ColumnControl Ajax search sends JS function instead of plain value

ColumnControl Ajax search sends JS function instead of plain value

raaazzaraaazza Posts: 1Questions: 1Answers: 0

When using DataTables with ColumnControl the Ajax payload for a column with a columnControl search contains a serialized JavaScript function instead of the actual search value. This breaks backend filtering because PHP cannot execute JS functions.

Column how i use is below:

{
    title: 'id',
    data: 'id',
    name: 'id',
    width: '20%',
    searchable: true,
    orderable: true,
    columnControl: [
        'order',
        {
            extend: 'dropdown',
            content: [
                'orderAsc',
                'orderDesc',
                'orderClear', 'spacer', 'search',
                'searchClear'
            ],
            ajaxOnly: true
        }
    ],
},

Payload received in PHP as follows:

array:5 [
  "data" => "id"
  "name" => "id"
  "searchable" => "true"
  "orderable" => "true"
  "search" => array:3 [
    "value" => null
    "regex" => "false"
    "fixed" => array:1 [
      0 => array:2 [
        "name" => "dtcc"
        "term" => """
          function(haystack) {
            return stringToNum(haystack) == searchTerm;
          }
        """
      ]
    ]
  ]
]

How to resolve it?

Answers

  • allanallan Posts: 65,056Questions: 1Answers: 10,772 Site admin

    ColumnControl does not yet support server-side processing.

    I have actually recently committed changes to the main branch to add support for this, and I expect it to be released next week, along with Editor 2.5, which will have support for it in the server-side libraries.

    Allan

Sign In or Register to comment.