0.4.2 • Published 6 years ago

simter-vue-thead v0.4.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Vue Component simter-vue-thead

Define table's thead tag by structured data. Such as columns = ["X1", "X2"] or columns = ["X1", {label: "X2", children: ["X21", "X22"]}]. Demo or document is here.

Core properties:

Name_RequireValueTypeDescription
columnstrue[{}]Define table columns
├ labeltrueStringThe column's visible text
├ widthfalseStringThe column's width, such as '2em'
├ childrenfalse[{}]The child group columns. id and width will be ignored if define this property
├ headerClassfalseStringThe specific class for this column's header cell th element
├ headerStylefalseStringThe specific style for this column's header cell th element
classesfalse{}Define component class
├ theadfalseStringthead class, follow Vue Class Bindings
├ rowfalseStringthead/tr class, follow Vue Class Bindings
├ cellfalseStringthead/tr/th class, follow Vue Class Bindings
stylesfalse{}Define component style
├ theadfalseStringthead class, follow Vue Style Bindings
├ rowfalseStringthead/tr class, follow Vue Style Bindings
├ cellfalseStringthead/tr/th class, follow Vue Style Bindings

Develop

yarn install  // or npm install
npm run dev

Use parcel to run the development debug.

Build

npm run build

Use rollup package the component to dist directory.

Usage

Example 1 : Simple Columns

Js:

import thead from 'simter-vue-thead'

new Vue({
  el: "#sample",
  data: {
    columns: ["X1", "X2", "X3"]
  },
  components: {
    "st-thead": thead
  }
})

Html template:

<table id="#sample">
  <thead is="st-thead" :columns="columns"></thead>
  ...
</table>

Generated html:

| X1 | X2 | X3 |
<table>
  <thead>
    <tr>
      <th>X1</th>
      <th>X2</th>
      <th>X3</th>
    </tr>
  </thead>
  ...
</table>

Example 2 : Group Columns

Use children key to define the group.

Js:

import thead from 'simter-vue-thead'

new Vue({
  el: "#sample",
  data: {
    columns: [
      "X1",
      {
        label: "X2",
        children: ["X21", "X22"]
      },
      {
        label: "X3",
        children: ["X31", "X32"]
      },
    ]
  },
  components: {
    "st-thead": thead
  }
})

Html template:

<table id="#sample">
  <thead is="st-thead" :columns="columns"></thead>
  ...
</table>

Generated html:

| X1 |    X2     |    X3     |
|    | X21 | X22 | X31 | X32 |
<table>
  <thead>
    <tr>
      <th rowspan="2">X1</th>
      <th colspan="2">X2</th>
      <th colspan="2">X3</th>
    </tr>
    <tr>
      <th>X21</th>
      <th>X22</th>
      <th>X31</th>
      <th>X32</th>
    </tr>
  </thead>
  ...
</table>

Example 3 : Complex Group Columns

Use children key to define any level nested group columns.

Js:

import thead from 'simter-vue-thead'

new Vue({
  el: "#sample",
  data: {
    columns: [
      { label: "X1" },
      {
        label: "X2",
        children: [
          { label: "X21" },
          { label: "X22" }
        ]
      },
      { label: "X3" },
      {
        label: "X4",
        children: [
          {
            label: "X41",
            children: [
              { label: "X411" },
              { label: "X412" }
            ]
          },
          { label: "X42" }
        ]
      }
    ]
  },
  components: {
    "st-thead": thead
  }
})

Html template:

<table id="#sample">
  <thead is="st-thead" :columns="columns"></thead>
  ...
</table>

Generated html:

| X1 |    X2     | X3 |        X4         |
|    | X21 | X22 |    |     X41     | X42 |
|    |     |     |    | X411 | X412 |     |
<table>
  <thead>
    <tr>
      <th rowspan="3">X1</th>
      <th colspan="2">X2</th>
      <th rowspan="3">X3</th>
      <th colspan="3">X4</th>
    </tr>
    <tr>
      <th rowspan="2">X21</th>
      <th rowspan="2">X22</th>
      <th colspan="2">X41</th>
      <th rowspan="2">X42</th>
    </tr>
    <tr>
      <th>X411</th>
      <th>X412</th>
    </tr>
  </thead>
  ...
</table>
0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago