Skip to content

Commit b993ae0

Browse files
authored
Merge pull request #20 from ks-labs/feature/add-new-treegrid-functions
Feature/add new treegrid functions
2 parents 1b334df + 3827733 commit b993ae0

File tree

3 files changed

+43
-22
lines changed

3 files changed

+43
-22
lines changed

README.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ Vue.use(TreeGrid);
5757
:rows="rows"
5858
:columns="columns"
5959
:rowStyle="rowStyle"
60+
:formatNoMatches="formatNoMatches"
6061
@onPostBody="onPostBody"
6162
@onClickRow="onClickRow"
6263
@headerStyle="headerStyle"
63-
@formatNoMatches="formatNoMatches"
6464
>
6565
</treegrid>
6666
</div>
@@ -165,24 +165,29 @@ Below are some configurations supported by the component, if you need a new conf
165165
166166
## Props
167167
168-
| Name | Type | Default | Description |
169-
| ------------- | -------- | ------- | ------------------------------------------------------------------ |
170-
| Rows | Array | | All table body data |
171-
| Columns | Array | | All data on column headings |
172-
| idField | String | id | Overwrite the default idField to 'id' |
173-
| parentIdField | String | pid | Set the parent id field. |
174-
| treeShowField | String | | Set the treeShowField will auto enable the tree grid. |
175-
| rootParentId | String | null | Set the root parent id. |
176-
| treeEnable | Boolean | false | Set true to enable the tree grid. |
177-
| stickyHeader | Boolean | false | Set true to use sticky header. |
178-
| clickColor | String | | Color displayed in the background when clicking on a line |
179-
| rowStyle | Function | {} | The row style formatter function, takes two parameters: row, index |
168+
| Name | Type | Default | Description |
169+
| --------------- | -------- | ------- | ------------------------------------------------------------------ |
170+
| Rows | Array | | All table body data |
171+
| Columns | Array | | All data on column headings |
172+
| idField | String | id | Overwrite the default idField to 'id' |
173+
| parentIdField | String | pid | Set the parent id field. |
174+
| treeShowField | String | | Set the treeShowField will auto enable the tree grid. |
175+
| rootParentId | String | null | Set the root parent id. |
176+
| treeEnable | Boolean | false | Set true to enable the tree grid. |
177+
| stickyHeader | Boolean | false | Set true to use sticky header. |
178+
| clickColor | String | | Color displayed in the background when clicking on a line |
179+
| rowStyle | Function | {} | The row style formatter function, takes two parameters: row, index |
180+
| formatNoMatches | Function | '' | Set message when the rows array is empty |
180181
181182
## Events
182183
183-
| Name | Description | params |
184-
| --------------- | -------------------------------------------------------------------------------------------- | ------------------------------ |
185-
| onPostBody | It fires after the table body are rendered and available in the DOM. The parameters contain: | element treegrid |
186-
| onClickRow | It fires when the user clicks a row | Object: {row, $element, field} |
187-
| headerStyle | The header style formatter function | column |
188-
| formatNoMatches | -- | |
184+
| Name | Description | params |
185+
| -------------- | -------------------------------------------------------------------------------------------- | ------------------------------------- |
186+
| onPostBody | It fires after the table body are rendered and available in the DOM. The parameters contain: | element treegrid |
187+
| onClickRow | It fires when the user clicks a row | Object: {row, $element, field} |
188+
| onClickCell | It fires when the user clicks a cell | Object: {field, value, row, $element} |
189+
| onDblClickRow | It fires when the user double clicks a row | Object: {row, $element, field} |
190+
| onDblClickCell | It fires when the user double clicks a cell | Object: {field, value, row, $element} |
191+
| onExpandRow | It fires when you click the detail icon to expand the detail view | Object: { index, row, $detail} |
192+
| onCollapseRow | It fires when you click the detail icon to collapse the detail view | Object: {index, row, detailView} |
193+
| headerStyle | The header style formatter function | column |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ks-labs/treegrid",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"author": "Victor Lessa victordsgnr@gmail.com",
55
"main": "src/wrapper.js",
66
"module": "dist/vue-treegrid.esm.js",

src/vue-treegrid.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ export default {
2828
type: String,
2929
default: "table table-bordered text-nowrap",
3030
},
31+
formatNoMatches: {
32+
type: Function,
33+
default: function () {
34+
return "";
35+
},
36+
},
3137
stickyHeader: {
3238
type: Boolean,
3339
default: true,
@@ -76,12 +82,22 @@ export default {
7682
stickyHeader: this.stickyHeader,
7783
treeShowField: this.treeShowField,
7884
parentIdField: this.parentIdField,
85+
rowStyle: this.rowStyle,
7986
onPostBody: () => this.$emit("onPostBody", treeGrid),
8087
onClickRow: (row, element, field) =>
8188
this.$emit("onClickRow", { row, element, field }),
89+
onClickCell: (field, value, row, element) =>
90+
this.$emit("onClickCell", { field, value, row, element }),
91+
onDblClickRow: (row, element, field) =>
92+
this.$emit("onDblClickRow", { row, element, field }),
93+
onDblClickCell: (field, value, row, element) =>
94+
this.$emit("onDblClickCell", { field, value, row, element }),
95+
onExpandRow: (index, row, detail) =>
96+
this.$emit("onExpandRow", { index, row, detail }),
97+
onCollapseRow: (index, row, detailView) =>
98+
this.$emit("onCollapseRow", { index, row, detailView }),
8299
headerStyle: (column) => this.$emit("headerStyle", column),
83-
rowStyle: this.rowStyle,
84-
formatNoMatches: () => this.$emit("formatNoMatches"),
100+
formatNoMatches: () => this.formatNoMatches(),
85101
});
86102
},
87103
},

0 commit comments

Comments
 (0)