Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82284

Pre-select doesn't work

$
0
0

I use select2 in conjunction with datatables editor.

let editor = new $.fn.dataTable.Editor({
  fields: [{
    label: label,
    name: name,
    type: 'select2',
    opts: {
      multiple: true,
      data: (params) => ({ search: params.term, type: 'public' }),
      ajax: {
        url: url,
        dataType: 'json',
      }
    }
  }]
})

Response from server:

{
  "results": [
    {
      "id": 1,
      "text": "Option 1",
      "selected": true // not even "selected": "selected"
    }
  ]
}

but it's not pre-selected. Is it due the plugin or the library?


Viewing all articles
Browse latest Browse all 82284

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>