MicroDroid / vue-materialize-datatable

A fancy Materialize CSS datatable VueJS component.
https://overcoder.dev/vue-materialize-datatable
MIT License
179 stars 67 forks source link

Sort changing Rows Per Page to default #44

Closed rmondc closed 4 years ago

rmondc commented 5 years ago

My default row per page is 10. But when I set it to a 100 and sort by clicking the column header, it returned to my default row per page of 10, instead of showing the 100 rows.

Why does this.currentPerPage go back to default after sort?

sort: function(index) {
      if (!this.sortable) return;
      if (this.sortColumn === index) {
        this.sortType = this.sortType === "asc" ? "desc" : "asc";
      } else {
        this.sortType = "asc";
        this.sortColumn = index;
      }
    },

Looks like its from

computed: {
...
        this.currentPerPage = options[0];
...
}

I change the above to this.currentPerPage = this.currentPerPage as a work around but not sure what will it affect.

MicroDroid commented 4 years ago

I couldn't reproduce this issue. However, I suspect it happens because your per-page options are changing right after sorting for some reason, causing resetting this.currentPerPage internally as you mentioned.

While I have removed that piece of code and replaced it with a watcher, it may still occur for you if you have some issues in your own code.