How do I use drawCallback function in Vue 3

How do I use drawCallback function in Vue 3

ZubyZuby Posts: 14Questions: 4Answers: 0

In vue 3, i am forced to set up the components options as a const object and then bind it to :options in the datatable component.
but that doesn't work for the drawCallback function. Pls how can I implement the drawCallback in a vue3 databletable component?

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    You could use add it into the list of options - see an example here.

    This is just adding the drawCallback like this:

    const options = {
      dom: 'Bftip',
      select: true,
      drawCallback: function() {
        console.log('inside drawcallback')
      }
    };
    

    Colin

  • ZubyZuby Posts: 14Questions: 4Answers: 0
    edited July 2023

    Thank you so much for your response. But when I tried this like I did on the dataTable i worked on outside view with the row and data, i had access to them. like this

    rowCallback: (row, data) => {
    if (! data.wasReviewed) {
    row.classList.add('fw-bold')
    }
    return row
    }

    but when I try it like you showed me here I get an error cause the options object doesn't have access to the rows instances and the row data

  • ZubyZuby Posts: 14Questions: 4Answers: 0

    What I'm actually trying to do is in this but this question wasn't answered. So am I on the right track?
    https://datatables.net/forums/discussion/36369/trying-to-open-all-child-rows-using-drawcallback

    can I do this

    drawCallback: (row, data) => { row.child(format(data)).show()}

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,953
    edited July 2023 Answer ✓

    drawCallback: (row, data) => { row.child(format(data)).show()}

    Sounds like you might want to use rowCallback instead of drawCallback. rowCallback has the function parameters of row and data but drawCallback has only the settings parameter.

    Kevin

  • ZubyZuby Posts: 14Questions: 4Answers: 0

    Oh, great. Thank you, i'll try that

Sign In or Register to comment.