Custom Template

Build your own UI

As of version 2 the package offers the ability to seamlessly swap any table component with your own UI implementation.

Usage

Swapped components are declared as the fifth argument you pass when registering the component:

Vue.use(ClientTable, [options = {}], [useVuex = false], [theme = 'bootstrap3'], {
    [componentAKey]: ComponentA,
    [componentBKey]: ComponentB,
    //etc...
});

Each component has its current template stored in the Github repo under the templates folder. All components have a single props prop, which is an object containing all contextual data needed to build the component. More on this in the examples section. The full structure of the components tree, along with the corresponding keys is listed below:

All components provide an opts property, referencing the full options object (i.e the merged default, global and local options)

Examples

Custom Pagination

Let's swap the default pagination, which uses vue-pagination-2, with some other 3rd party implementaion, say vue-plain-pagination .

Copy the existing pagination template:

Modify it like so, and save to your project:

MyPagination.vue

Register it:

Et Voila!

In this example we used the totalPages prop, which wasn't used in the original component. If you encounter a use-case for other props which are not exposed through the props object, let me know and I'll consider adding it to the provided properties

Font Awesome Sort Icon

Let's use vue-fontawesome

Install the icons:

Copy the original template:

Modify and save to your project:

MySortControl.vue

As in the example above, note we are using the sortStatus property. which wasn't used in the original template

Register it:

In this example we will reposition the pagination element inside the table by moving it from VtDataTable to VtTable:

Remove pagination from VtDataTable:

MyDataTable.vue

Add pagination to VtTable:

MyTable.vue

Register Components:

Add vtHeadingsRow to vtTable:

MyTable.vue

Register the component:

Numeric Field Pagination

Say you have a huge number of pages in your server table, which prevents you from using dropdown pagination due to memory limitations. Let's replace dropdown pagination (VtDropdownPagination) with a numeric field.

NumericFieldPagination.vue

Register the component:

Select2 List Filter

Replace VtListFilter with the following:

Register the component:

Vuetify

VtDataTable:

VtTable:

VtPagination:

VtPerPageSelector:

VtGenericFilter (remove label):

VtSortControl:

Register the components:

Filter on button click

By default, the generic filter is triggered on key up. Here is how to trigger it on click instead:

VtGenericFilter.vue:

Register the component:

Last updated

Was this helpful?