Can I invoke the draw() function on a Datatablevue3 component?
Can I invoke the draw() function on a Datatablevue3 component?
![Zuby](https://secure.gravatar.com/avatar/49aae53a9185f080c58e4b00f577df5f/?default=https%3A%2F%2Fvanillicon.com%2F49aae53a9185f080c58e4b00f577df5f_200.png&rating=g&size=120)
Description of problem:
I'm building an app and I want to use Datatables with Vue 3 and bootstrap 5 with the serverside option. I'll be using Datatables is a lot of pages and I don't want to get the data independently and populate the table using the data option. It would mean that I'll have to load the entire data into the clientside. In a previous app I did with datatables I used the draw() function to dynamically display the latest records on the table. But with the Datatablevue3, how can I call a function that makes the Ajax call to refresh the data of the table
This question has accepted answers - jump to:
Answers
You can grab a DataTables API reference as described here. You'll then be able to call
draw()
on it.Allan
Oh wow. I read that vue installation doc many times but I just didn't get that part. Let me try it. Thanks a lot.
But i don't fully understand the code.
this is the example
if we use let to declare dt. How come dt is appended here table.value.dt and then assigned to dt? I understand the ref and the const table. Pls could you explain a little more.. pls. It will help me know how to use it better
Vue will make a reference we can access via the
table
variable (line 2). That reference then has avalue.dt
property which is assigned by the Vue DataTables component. That is the API reference. We use line 5 to assign it to the simpledt
variable for use.I don't massively like that part of the API either... Its a little bit too much like "magic"![:) :)](https://datatables.net/forums/resources/emoji/smile.png)
Allan
Yes it does look like magic. I starred at it for a while. Means I can call the variable anything. Great! Your explanation has lifted a lot off my shoulders. Oh thanks alot Allan
Places you right into one of the two really hard problems in programming...![;) ;)](https://datatables.net/forums/resources/emoji/wink.png)
Allan