File tree Expand file tree Collapse file tree 2 files changed +35
-5
lines changed Expand file tree Collapse file tree 2 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ rows => Rows. => [
87
87
]
88
88
perPage => Number of rows per.. page => 10 (default) // Results per page
89
89
onClick => Func. to execute on click => console.log // Function, row 1st param
90
+ clickable => Rows are clickable. => true (default) //row is passed in the event payload
91
+ Will fire `row-click` event //see react to click on row (below)
90
92
sortable => Cause column-click to sort => true (default) // Whether sortable
91
93
searchable => Add fuzzy search functionality => true (default) // Whether searchable
92
94
exactSearch => Disable fuzzy search => true (default) // Whether only exact matches are returned
@@ -101,3 +103,28 @@ customButtons => Custom buttons thingy => [
101
103
}
102
104
]
103
105
```
106
+
107
+ ### React to click on row
108
+
109
+ The datatable will emit the ` row-click ` event if ` clickable ` is set to ` true ` (default).
110
+
111
+ The events payload will contain the ` row object ` , you can bind to the event like this:
112
+
113
+ ``` html
114
+ <datatable v-on:row-click =" onRowClick" ></datatable >
115
+
116
+ <script >
117
+ var app = new Vue ({
118
+ el: ' #app' ,
119
+ ...
120
+ methods: {
121
+ onRowClick : function (row ) {
122
+ // row contains the clicked object from `rows`
123
+ console .log (row)
124
+ }
125
+ },
126
+ })
127
+ </script >
128
+ ...
129
+
130
+ ```
Original file line number Diff line number Diff line change 56
56
</thead >
57
57
58
58
<tbody >
59
- <tr v-for =" (row, index) in paginated" :class =" onClick ? ' clickable' : '' " @click =" click(row, index )" >
59
+ <tr v-for =" (row, index) in paginated" :class =" { clickable : clickable } " @click =" click(row)" >
60
60
<td v-for =" column in columns" :class =" column.numeric ? 'numeric' : ''" v-if =" !column.html" >
61
61
{{ collect(row, column.field) }}
62
62
</td >
111
111
title: ' ' ,
112
112
columns: {},
113
113
rows: {},
114
- onClick : {},
114
+ clickable : {default : true },
115
115
customButtons: {default : () => []},
116
116
perPage: {default: 10 },
117
117
sortable: {default: true },
164
164
this .searching = ! this .searching ;
165
165
},
166
166
167
- click : function (row , index ) {
168
- if (this .onClick )
169
- this .onClick (row, index);
167
+ click : function (row ) {
168
+ if (! this .clickable ){
169
+ return
170
+ }
171
+
172
+ this .$emit (' row-click' , row)
170
173
},
171
174
172
175
exportExcel : function () {
You can’t perform that action at this time.
0 commit comments