Vue Component simter-vue-table
A Vue component used to generate HTML table element.
Options:
Name___________ | Require | ValueType | Description |
---|---|---|---|
columns | true | [{}] | Define table columns |
├ id | false | String | The column's id, it's the key in the rows item |
├ label | true | String | The column's visible text |
├ width | false | String | The column's width, such as '2em' |
├ children | false | [{}] | The child group columns. id and width will be ignored if define this property |
├ headerClass | false | String | This column's thead/tr/th element class, follow Vue Class Bindings |
├ headerStyle | false | String | This column's thead/tr/th element style, follow Vue Class Bindings |
├ class | false | String | This column's tbody/tr/td element class, follow Vue Class Bindings |
├ style | false | String | This column's tbody/tr/td element style, follow Vue Class Bindings |
├ cell | false | {} String |
Define cell customized, String type means setting component value |
│ ├ component | false | String | The cell component's name |
│ ├ classes | false | {} | Define the cell's inner dom elements classes, keys is up to the component design |
│ ├ styles | false | {} | Define the cell's inner dom elements styles, keys is up to the component design |
│ ├ ...custom | false | custom | The custom properties for all this column's cell component. It is up to the component design |
rows | true | [{}] | The table's row data |
classes | false | {} | Define inner dom elements global classes |
├ headerRow | false | String | thead/tr class, follow Vue Class Bindings |
├ headerCell | false | String | thead/tr/td class, follow Vue Class Bindings |
├ row | false | String | tbody/tr class, follow Vue Class Bindings |
├ cell | false | String | tbody/tr/td class, follow Vue Class Bindings |
├ groupRow | false | String | group tbody/tr class, follow Vue Class Bindings |
├ groupCell | false | String | group tbody/tr/td class, follow Vue Class Bindings |
├ table | false | String | table class, follow Vue Class Bindings |
├ thead | false | String | thead class, follow Vue Class Bindings |
├ tbody | false | String | tbody class, follow Vue Class Bindings |
styles | false | {} | Define inner dom elements global styles, simular to classes prop |
group | false | {} String Boolean Function |
Define how to predicate a group row. String type means setting id value with predicate=true . Boolean or Function type means setting predicate value with id='group' . |
├ id | false | String | The key in the row item to get the group cell value |
├ predicate | false | String Function |
Generate a bool value to predicate whether this row is a group row - String: The row item's key that to get the bool value - Function: Call to get the bool value. It's first param is the current row data |
├ indent | false | Boolean String |
Predicate whether to indent children row or not. Default is true. String type means setting a specific indent style, such as padding-left:2em |
├ cell | false | {} String |
The group cell component config, same as columns[i].cell |
├ colspan | false | Number | The group cell's colspan attribute value. Default behavior is to merge all the column cell |
picker | false | {} String Boolean |
Define the picker column cell. String type means setting component value. Boolean type means whether to show a default picker cell column. |
├ id | false | String | The key in the row item to get the picked value |
├ component | false | String | The cell component's name |
├ classes | false | {} | Define the picker cell's inner dom elements classes, keys is up to the component design |
├ styles | false | {} | Define the picker cell's inner dom elements styles, keys is up to the component design |
├ ...custom | false | custom | The custom properties for this picker cell component. It is up to the component design |
id | false | String | The key in row item that use its value to unique table row identity |
Develop
yarn install // or npm install
yarn run dev // or npm run dev
Use [parcel] to run the development debug.
Build
yarn run build // or npm run build
Use [rollup] package the component to dist
directory.
Usage
Example 1 : Simple Columns
Js:
Html template:
Generated html:
Example 2 : Group Columns
Use children
key to define the group.
Js:
Html template:
Generated html:
Example 3 : Complex Group Columns
Use children
key to define any level nested group columns.
Js:
Html template:
Generated html: