Trigger q-table refresh [solved]



  • I have q-table with data from server. When creating new record i want to refresh data from server. I don’t understand how to do this.



  • @star You can just call the method you use for @request property, with the current pagination and filter objects if you use them :

    // Attached to @request prop of q-table
    onRequest(prop) {
          const { page, rowsPerPage, sortBy, descending } = props.pagination
          const filter = props.filter
    // ...
    }
    
    onAddRecord() {
      // add the record
      // ...
      // Refresh
      this.onRequest({ filter: this.filter, pagination : this.pagination})
    }
    


  • @tof06 Thank You! It works like a charm. I don’t know why I didn’t think of it.



  • @tof06 Do you have a fully sample code on this? Thanks!



  • @Rusli-Cali No I don’t.

    The full code would depend on a lot of stuff, how you are requesting data, if you are filtering or ordering them, how you are updating them…

    If you have any problem with my answer, post your code and I’ll try to help you.
    But basically, all you need is to call the @request event handler (which must be defined when you want to
    filter, order or paginate serverside) just after the new record has been created. This will fetch fresh data from the server, and update the table.


Log in to reply