Select extension - How can i pre-select a row, according to the value of an ajax request

Select extension - How can i pre-select a row, according to the value of an ajax request

EduardoDosEduardoDos Posts: 2Questions: 2Answers: 0
edited August 2019 in Free community support

I have to mark as selected according to the values from my database how can i do it ?

$('#category'+categoryId).DataTable({
    "processing": true,
    "bLengthChange": false,
    'deferRender': true,
    'select': true,
    "ajax": {
      "url": researchUrl,
      "type": "GET"
    },
    "stateSave": true,
    "columns": [
      {'data': ''},
      {'data': 'company_name'},
      {'data': 'phone'},
      {'data': 'email'}
    ],
    'columnDefs': [{
      'targets': 0,
      'defaultContent': '',
      'orderable': false,
      'className': 'select-checkbox'
    }],
    'select': {
      'style': 'multi',
      'selector': 'td:first-child'
    }
  })

Answers

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi EduardoDos,

    When using ajax you need to use the initComplete function to wait until the data is loaded and then use row().select() to select the row.

    Thanks,

    Sandy

This discussion has been closed.