Vue 3 datatable Individual column searching dropdown.

Vue 3 datatable Individual column searching dropdown.

draw134draw134 Posts: 12Questions: 4Answers: 0

Is this possible in vue 3?

currently my implentation is

            <DataTable class="display" ref="table" id="example">
                  <th>Degree Type</th>
                <tr v-for="submission in formattedSubmissions" :key="">
                  <td>{{ submission.formattedDate }}</td>
                  <td>{{ submission.title }}</td>
                  <td>{{ }}</td>
                  <td>{{ submission.user.degree_type.toUpperCase() }}</td>
                  <td v-html="statusBadge(submission)"></td>
                  <td>{{ submission.adviser }}</td>
                  <td>{{ }}</td>
                  <td>{{ submission.panels }}</td>
                    <Link :href="`/wala`" class="btn btn-sm um-button">View</Link>

and I tried something like

const initializeDataTable = () => {
  const table = new DataTable('#example', {
    initComplete: function () {
        .every(function () {
          let column = this;

          // Create select element
          let select = document.createElement('select');
          select.add(new Option(''));

          // Apply listener for user change in value
          select.addEventListener('change', function () {
            var val = DataTable.util.escapeRegex(select.value);

              .search(val ? '^' + val + '$' : '', true, false)

          // Add list of options
            .each(function (d, j) {
              select.add(new Option(d));

onMounted(() => {

and it says DataTable is not a constructor. Can someone correct my usage? Thanks


  • allanallan Posts: 60,278Questions: 1Answers: 9,785 Site admin


    You can't use v-for with the DataTable component. The problem with it is that it would result in both DataTables and Vue trying to control the same DOM elements in the tbody. That is never going to work unfortunately.

    You need to pass the data to DataTables from your data (formattedSubmissions in this case) as shown in the documentation.

    Unfortunately you can't yet use Vue components in the table cells with a DataTable. That is a limitation I'm looking into.

    I doubt that is the actual issue you are facing, but I'd need a test case showing the issue to be able to diagnose it, as I don't see how you are doing your imports or even if you are using our Vue3 component. However, the approach above just won't work at all I'm afraid - because of that issue with trying to control the same DOM.


Sign In or Register to comment.