ratiw / vuetable-2-tutorial

MIT License
258 stars 67 forks source link

Does pagination work on dataMode (apiMode=false)? #55

Closed vcanales closed 4 years ago

vcanales commented 7 years ago

I've been trying this:

     <article class="tile is-child box">
          <vuetable
            ref="clientsTable"
            :apiMode=false
            :fields="[
              'id',
              'name',
              'email',
              {
                name: 'created_at',
                title: 'Created',
                callback: 'dateFilter|shortDate',
              },
              'confirmed',
            ]"
            pagination-path=""
            @vuetable:pagination-data="onPaginationData"
          />
          <vuetable-pagination-info
            ref="paginationInfo"
          />
          <vuetable-pagination
            ref="pagination"
            @vuetable-pagination:change-page="onChangePage"
          ></vuetable-pagination>
        </article>
      </div>
import VueTable, {
  VuetablePagination,
  VuetablePaginationInfo,
} from 'vuetable-2';
import { mapActions, mapGetters } from 'vuex';
import { dateFilter } from '@/utils/formatDates';

export default {
  name: 'clients',
  components: {
    vuetable: VueTable,
    'vuetable-pagination': VuetablePagination,
    'vuetable-pagination-info': VuetablePaginationInfo,
  },
  mounted() {
    this.getUsers()
    .then(data => this.$refs.clientsTable.setData(data));
  },
  methods: {
    ...mapActions(['getUsers']),
    dateFilter,
    onPaginationData(paginationData) {
      this.$refs.pagination.setPaginationData(paginationData);
      this.$refs.paginationInfo.setPaginationData(paginationData);
    },
    onChangePage(page) {
      this.$refs.clientsTable.changePage(page);
    },
  },
  computed: {
    ...mapGetters(['clients']),
  },
};

But it ends up displaying No relevant dataand the table is not paginated, even though it has 455 rows.

ratiw commented 7 years ago

@vcanales Yes, it does but only if you provide the data in that contain pagination information. That also means the data you pass in setData method must be an Object. Please see the example in this codepen.

One thing that is not quite finalized for me is the use of data-total prop, but I still don't have enough time to revise it.