Vue Material -

Table


by Creative Tim
Docs
Components
Premium themes

Data tables display sets of raw data. They usually appear in desktop enterprise products. They have more features than any other component in the Vue Material ecosystem. There are a lot of options that you can tweak to change and impact the table layout.

This component is still WIP. Right now you can use the core basic stuff, but soon we will release Pagination, Internal search and Edit options. The current API will not change during the beta phase (likely).

Simple tables

To create a basic table, with simple data and without any advanced options, you have a really simple markup to use.

There are some components that mimic the native table elements:

  • md-table => table
  • md-table-row => tr
  • md-table-head => th
  • md-table-cell => td
Basic Table
ID
Name
Email
Gender
Job Title
1
Shawna Dubbin
sdubbin0@geocities.com
Male
Assistant Media Planner
2
Odette Demageard
odemageard1@spotify.com
Female
Account Coordinator
3
Vera Taleworth
vtaleworth2@google.ca
Male
Community Outreach Specialist

In pages that only have a table, you can put this table within a card. Fortunately Vue Material provides an option out of the box to add a table card without any effort:

Table within a card

Users

ID
Name
Email
Gender
Job Title
1
Shawna Dubbin
sdubbin0@geocities.com
Male
Assistant Media Planner
2
Odette Demageard
odemageard1@spotify.com
Female
Account Coordinator
3
Vera Taleworth
vtaleworth2@google.ca
Male
Community Outreach Specialist

Advanced tables

This section will assume that you have knowledge of Vue Scoped Slots. You'll need them to create advanced tables.

Vue Material have advanced tables that can handle with your data, sorting, selecting and manipulating it. You can pass a v-model with you data and tweak the table to suit your needs. Along with that, you should give to data table a custom template. This will allow the table to have its own markup and display all rows for you. This is really powerfull!

There are plenty of options for you to make your data table awesome, so carefully read this documentation, analyze the code examples with full attention and take a deeper look at the API section.

Let's start with a custom template feature:

When you provide a model along with a custom template, the data table will render the whole Array of options for you, without the need of a v-for, for example:

Custom template

Users

ID
Name
Email
Gender
Job Title
1
Shawna Dubbin
sdubbin0@geocities.com
Male
Assistant Media Planner
2
Odette Demageard
odemageard1@spotify.com
Female
Account Coordinator
3
Lonnie Izkovitz
lizkovitz3@youtu.be
Female
Operator
4
Thatcher Stave
tstave4@reference.com
Male
Software Test Engineer III
5
Clarinda Marieton
cmarietonh@theatlantic.com
Female
Paralegal

With a custom template, a model and some other properties, you can have automatic sort:

Sort

Users

ID
Name
Email
Gender
Job Title
5
Clarinda Marieton
cmarietonh@theatlantic.com
Female
Paralegal
3
Lonnie Izkovitz
lizkovitz3@youtu.be
Female
Operator
2
Odette Demageard
odemageard1@spotify.com
Female
Account Coordinator
1
Shawna Dubbin
sdubbin0@geocities.com
Male
Assistant Media Planner
4
Thatcher Stave
tstave4@reference.com
Male
Software Test Engineer III

Sometimes the internal sort from Vue Material will not be enough for you. You can provide your own sort function:

Custom Sort function

Users

ID
Name
Email
Gender
Job Title
4
Thatcher Stave
tstave4@reference.com
Male
Software Test Engineer III
1
Shawna Dubbin
sdubbin0@geocities.com
Male
Assistant Media Planner
2
Odette Demageard
odemageard1@spotify.com
Female
Account Coordinator
3
Lonnie Izkovitz
lizkovitz3@youtu.be
Female
Operator
5
Clarinda Marieton
cmarietonh@theatlantic.com
Female
Paralegal

With large datasets comes great responsibility... with your user. We know that Vue Material tables have a great layout, but we need to care about the usability of your screens. Fixed headers will make it easier to interact with the table by keeping all options always visible:

Fixed headers

Users

ID
Name
Email
Gender
Job Title
18
Clarinda Marieton
cmarietonh@theatlantic.com
Male
Paralegal
13
Cortney Caulket
ccaulketc@cbsnews.com
Male
Safety Technician IV
11
Cybill Rimington
crimingtona@usnews.com
Female
Assistant Professor
9
Gawen Applewhite
gapplewhite8@reverbnation.com
Female
GIS Technical Architect
7
Helge Holyard
hholyard6@howstuffworks.com
Female
Internal Auditor
15
Ingar Raggles
iragglese@cbc.ca
Female
VP Sales
6
Karim Chipping
kchipping5@scribd.com
Female
Safety Technician II
16
Karmen Mines
kminesf@topsy.com
Male
Administrative Officer
4
Lonnie Izkovitz
lizkovitz3@youtu.be
Female
Operator
20
Maura Thoms
mthomsj@webeden.co.uk
Male
Actuary
12
Maureene Eggleson
megglesonb@elpais.com
Male
Recruiting Manager
10
Nero Mulgrew
nmulgrew9@plala.or.jp
Female
Staff Scientist
2
Odette Demageard
odemageard1@spotify.com
Female
Account Coordinator
19
Paxon Lotterington
plotteringtoni@netvibes.com
Female
Marketing Assistant
8
Rod Titterton
rtitterton7@nydailynews.com
Male
Technical Writer
17
Salome Judron
sjudrong@jigsy.com
Male
Staff Scientist
14
Selig Swynfen
sswynfend@cpanel.net
Female
Environmental Specialist
1
Shawna Dubbin
sdubbin0@geocities.com
Male
Assistant Media Planner
5
Thatcher Stave
tstave4@reference.com
Male
Software Test Engineer III
3
Vera Taleworth
vtaleworth2@google.ca
Male
Community Outreach Specialist

It's easy to integrate a search functionality on tables. You only need to change the model that you share with your table. You can also use the md-table-empty-state component to show an empty state when the search returns zero items:

Search and empty state

Users

ID
Name
Email
Gender
Job Title
18
Clarinda Marieton
cmarietonh@theatlantic.com
Male
Paralegal
13
Cortney Caulket
ccaulketc@cbsnews.com
Male
Safety Technician IV
11
Cybill Rimington
crimingtona@usnews.com
Female
Assistant Professor
9
Gawen Applewhite
gapplewhite8@reverbnation.com
Female
GIS Technical Architect
7
Helge Holyard
hholyard6@howstuffworks.com
Female
Internal Auditor
15
Ingar Raggles
iragglese@cbc.ca
Female
VP Sales
6
Karim Chipping
kchipping5@scribd.com
Female
Safety Technician II
16
Karmen Mines
kminesf@topsy.com
Male
Administrative Officer
4
Lonnie Izkovitz
lizkovitz3@youtu.be
Female
Operator
20
Maura Thoms
mthomsj@webeden.co.uk
Male
Actuary
12
Maureene Eggleson
megglesonb@elpais.com
Male
Recruiting Manager
10
Nero Mulgrew
nmulgrew9@plala.or.jp
Female
Staff Scientist
2
Odette Demageard
odemageard1@spotify.com
Female
Account Coordinator
19
Paxon Lotterington
plotteringtoni@netvibes.com
Female
Marketing Assistant
8
Rod Titterton
rtitterton7@nydailynews.com
Male
Technical Writer
17
Salome Judron
sjudrong@jigsy.com
Male
Staff Scientist
14
Selig Swynfen
sswynfend@cpanel.net
Female
Environmental Specialist
1
Shawna Dubbin
sdubbin0@geocities.com
Male
Assistant Media Planner
5
Thatcher Stave
tstave4@reference.com
Male
Software Test Engineer III
3
Vera Taleworth
vtaleworth2@google.ca
Male
Community Outreach Specialist

Selection

When dealing with large data sets, you may want to have quick actions over our data, like whether to remove or make some bulk change. Tables have inner selection in two ways: Single and Multiple.

The single selection is really great to highlight a particular item. Maybe, by clicking on a table row, will show the details of the item. With single selections you'll have access to the selected item and the table will do the rest. You can use the primary and accent hue colors to give more appealing highlight colors:

Single

Selection Colors

ID
Name
Email
Gender
Job Title
1
Shawna Dubbin
sdubbin0@geocities.com
Male
Assistant Media Planner
2
Odette Demageard
odemageard1@spotify.com
Female
Account Coordinator
3
Lonnie Izkovitz
lizkovitz3@youtu.be
Female
Operator
4
Thatcher Stave
tstave4@reference.com
Male
Software Test Engineer III
5
Clarinda Marieton
cmarietonh@theatlantic.com
Female
Paralegal

Selected:

{}

Multiple selections great for bulk changes and you can use the alternate header to hold the options that you can call when there are options selected. Note that if you click on the checkbox or on the entire row, it will do the same action due to md-auto-select option. Really handy:

Multiple

With auto select and alternate headers

Name
Email
Gender
Job Title
Shawna Dubbin
sdubbin0@geocities.com
Male
Assistant Media Planner
Odette Demageard
odemageard1@spotify.com
Female
Account Coordinator
Lonnie Izkovitz
lizkovitz3@youtu.be
Female
Operator
Thatcher Stave
tstave4@reference.com
Male
Software Test Engineer III
Clarinda Marieton
cmarietonh@theatlantic.com
Female
Paralegal

Selected:

[]

The table pagination will create the mechanism to show contents through pages.

Pagination

Users

ID
Name
Email
Gender
Job Title
1
Shawna Dubbin
sdubbin0@geocities.com
Male
Assistant Media Planner
2
Odette Demageard
odemageard1@spotify.com
Female
Account Coordinator
Rows per page:
  • 1–2 of 5

    Here's an example of a table controlled remotely through ajax.

    Remote pagination

    Users

    Rows per page:
  • -2–0 of

    API - md-table

    The following options can be applied to the md-table component:

    NameDescriptionDefault
    v-model Array The model variable to bind the input prompt value []
    md-model-id String Object property in the `v-model` array to use as :key id
    md-card Boolean Renders table as Card false
    md-sort String Lets you define a column to sort your data with null
    md-sort-order String Sort order asc
    md-sort-fn Function Custom sorting function String or Numeric sort depending on the column data
    md-height Number|String Sets the table height 400
    md-selected-value Array|Object Lets you provide a selected value. Eg.
    :md-selected-value.sync="selectedValue"
    null

    API - md-table-head & md-table-cell

    The following options can be applied to the head and cell components:

    NameDescriptionDefault
    md-id String|Number You can define an id for the cell null
    md-label String Specifies the cell’s header null
    md-numeric Boolean Aligns text to right false
    md-tooltip String Specify a tooltip null
    md-sort-by String   null

    API - md-table-pagination

    The following options can be applied to the pagination component:

    NameDescriptionDefault
    md-page-size Number Selected page size 10
    md-page-options Array Number of items per page available [5, 10, 25, 50, 100]
    md-update Function Provides an update of the current pagination status: page, pageSize, sort, sortOrder. If this function returns false it won’t update the component An empty function which returns true
    md-paginated-data Array Used in front end pagination, provides the paginated list of items. Please use as
    :md-paginated-data.sync="paginatedData"
    null
    md-data Array|Object If you need remote pagination please provide a structure like the following
    {
      mdCount: null,
      mdPage: null,
      mdData: []
    }
    Otherwise, if you need local pagination just provide the full list of unpaginated data:
    [{...}, {...}, ...]
    null