Skip to content

Commit 72936b0

Browse files
committed
support more props
1 parent 27e425d commit 72936b0

File tree

4 files changed

+105
-17
lines changed

4 files changed

+105
-17
lines changed

README.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@
9999
<td>Boolean</td>
100100
<td>true</td>
101101
</tr>
102+
<tr>
103+
<td>tableProps</td>
104+
<td></td>
105+
<td></td>
106+
<td>
107+
an object to pass any proptery to el-table. refer to <a href="http://element.eleme.io/#/en-US/component/table#table-attributes">el-table proptery</a>
108+
</td>
109+
<td>Object</td>
110+
<td>undefined</td>
111+
</tr>
102112
<tr>
103113
<td>actions-def</td>
104114
<td></td>
@@ -265,13 +275,29 @@
265275
<td>[]</td>
266276
</tr>
267277
<tr>
268-
<td rowspan="2"></td>
278+
<td rowspan="4"></td>
269279
<td>name</td>
270280
<td></td>
271281
<td>the row action button text</td>
272282
<td>String</td>
273283
<td>-</td>
274284
</tr>
285+
<tr>
286+
<td>type</td>
287+
<td></td>
288+
<td>type of the button</td>
289+
<td>String</td>
290+
<td>text</td>
291+
</tr>
292+
<tr>
293+
<td>buttonProps</td>
294+
<td></td>
295+
<td>
296+
an object to pass any proptery to el-button. refer to <a href="http://element.eleme.io/#/en-US/component/button#attributes">el-button proptery</a>
297+
</td>
298+
<td>Object</td>
299+
<td>undefined</td>
300+
</tr>
275301
<tr>
276302
<td>handler</td>
277303
<td></td>
@@ -323,28 +349,28 @@
323349
<td rowspan="4"></td>
324350
<td>layout</td>
325351
<td></td>
326-
<td>refer to <a href="http://element.eleme.io/#/zh-CN/component/pagination">Elmeme Doc</a></td>
352+
<td>refer to <a href="http://element.eleme.io/#/en-US/component/pagination">Elmeme Doc</a></td>
327353
<td>String</td>
328354
<td>[prev, pager, next, jumper, sizes, total]</td>
329355
</tr>
330356
<tr>
331357
<td>pageSize</td>
332358
<td></td>
333-
<td>refer to <a href="http://element.eleme.io/#/zh-CN/component/pagination">Elmeme Doc</a></td>
359+
<td>refer to <a href="http://element.eleme.io/#/en-US/component/pagination">Elmeme Doc</a></td>
334360
<td>Number</td>
335361
<td>20</td>
336362
</tr>
337363
<tr>
338364
<td>pageSizes</td>
339365
<td></td>
340-
<td>refer to <a href="http://element.eleme.io/#/zh-CN/component/pagination">Elmeme Doc</a></td>
366+
<td>refer to <a href="http://element.eleme.io/#/en-US/component/pagination">Elmeme Doc</a></td>
341367
<td>Array</td>
342368
<td>[20, 50, 100]</td>
343369
</tr>
344370
<tr>
345371
<td>currentPage</td>
346372
<td></td>
347-
<td>refer to <a href="http://element.eleme.io/#/zh-CN/component/pagination">Elmeme Doc</a></td>
373+
<td>refer to <a href="http://element.eleme.io/#/en-US/component/pagination">Elmeme Doc</a></td>
348374
<td>Number</td>
349375
<td>1</td>
350376
</tr>
@@ -369,6 +395,9 @@ For details, check the [Demo](https://njleonzhang.github.io/vue-data-tables/) an
369395
# install dependencies
370396
npm install
371397
372-
# serve demo with hot reload at localhost:8080
398+
# serve test/play with hot reload at localhost:8080
399+
npm run play
400+
401+
# serve docs with hot reload at localhost:8080
373402
npm run dev
374403
```

play/App.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515

1616
<template lang="pug">
1717
.app-wrapper
18-
data-tables(:data='tableData', :actions-def='getActionsDef()', :checkbox-filter-def='getCheckFilterDef()', :row-action-def='getRowActionsDef()')
18+
data-tables(
19+
:data='tableData',
20+
:actions-def='getActionsDef()',
21+
:actionColFixed='false',
22+
:checkbox-filter-def='getCheckFilterDef()',
23+
:row-action-def='getRowActionsDef()',
24+
:tableProps="{border: false, 'row-class-name':'test-class'}")
1925
el-table-column(prop='flow_no', label='No.', sortable='custom')
2026
el-table-column(prop='content', label='Content', sortable='custom')
2127
el-table-column(prop='create_time', label='Time', sortable='custom')
@@ -134,7 +140,7 @@
134140
},
135141
name: 'Edit'
136142
}, {
137-
type: 'primary',
143+
buttonProps: {icon: 'message'},
138144
handler(row) {
139145
self.$message('RUA in row clicked')
140146
console.log('RUA in row clicked', row)

readme_table_backup.pug

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,29 @@ table
1313
td The data array which will be render in the table.
1414
td Array
1515
td -
16+
tr
17+
td border
18+
td
19+
td
20+
td whether table has vertical border.
21+
td Boolean
22+
td true
23+
tr
24+
td stripe
25+
td
26+
td
27+
td whether table is striped.
28+
td Boolean
29+
td true
30+
tr
31+
td tableProps
32+
td
33+
td
34+
td
35+
| an object to pass any proptery to el-table. refer to
36+
a(href='http://element.eleme.io/#/en-US/component/table#table-attributes') el-table proptery
37+
td Object
38+
td undefined
1639
tr
1740
td actions-def
1841
td
@@ -163,12 +186,26 @@ table
163186
td Array
164187
td []
165188
tr
166-
td(rowspan='2')
189+
td(rowspan='4')
167190
td name
168191
td
169192
td the row action button text
170193
td String
171194
td -
195+
tr
196+
td type
197+
td
198+
td type of the button
199+
td String
200+
td text
201+
tr
202+
td buttonProps
203+
td
204+
td
205+
| an object to pass any proptery to el-button. refer to
206+
a(href='http://element.eleme.io/#/en-US/component/button#attributes') el-button proptery
207+
td Function
208+
td -
172209
tr
173210
td handler
174211
td
@@ -216,30 +253,30 @@ table
216253
td
217254
td
218255
| refer to
219-
a(href='http://element.eleme.io/#/zh-CN/component/pagination') Elmeme Doc
256+
a(href='http://element.eleme.io/#/en-US/component/pagination') Elmeme Doc
220257
td String
221258
td [prev, pager, next, jumper, sizes, total]
222259
tr
223260
td pageSize
224261
td
225262
td
226263
| refer to
227-
a(href='http://element.eleme.io/#/zh-CN/component/pagination') Elmeme Doc
264+
a(href='http://element.eleme.io/#/en-US/component/pagination') Elmeme Doc
228265
td Number
229266
td 20
230267
tr
231268
td pageSizes
232269
td
233270
td
234271
| refer to
235-
a(href='http://element.eleme.io/#/zh-CN/component/pagination') Elmeme Doc
272+
a(href='http://element.eleme.io/#/en-US/component/pagination') Elmeme Doc
236273
td Array
237274
td [20, 50, 100]
238275
tr
239276
td currentPage
240277
td
241278
td
242279
| refer to
243-
a(href='http://element.eleme.io/#/zh-CN/component/pagination') Elmeme Doc
280+
a(href='http://element.eleme.io/#/en-US/component/pagination') Elmeme Doc
244281
td Number
245282
td 1

src/components/DataTables.vue

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
:border="border",
5555
fit,
5656
:stripe="stripe",
57+
v-bind='tableProps',
5758
@row-click='handleRowClick',
5859
@selection-change='handleSelectChange',
5960
@select='handleSelect',
@@ -65,12 +66,14 @@
6566
prop='innerRowActions',
6667
inline-template,
6768
v-if='hasActionCol',
68-
:min-width='actionColWidth')
69+
:min-width='actionColWidth',
70+
:fixed='actionColFixed')
6971
div.action-list
70-
span(v-for='action in rowActionDef')
72+
span(v-for='action in innerRowActionDef')
7173
el-button(
72-
type='text',
73-
@click='action.handler(row)') {{action.name}}
74+
:type='action.type',
75+
@click='action.handler(row)'
76+
v-bind='action.buttonProps') {{action.name}}
7477

7578
.pagination-wrap
7679
el-pagination(
@@ -100,6 +103,15 @@ export default {
100103
offset: 0
101104
}, this.actionsDef)
102105
106+
this.innerRowActionDef = this.rowActionDef.map(el => {
107+
if (!el.type) {
108+
el.type = 'text'
109+
}
110+
return el
111+
})
112+
113+
console.log(this.innerRowActionDef)
114+
103115
this.innerCheckboxFilterDef = Object.assign({}, {
104116
props: undefined,
105117
def: [],
@@ -143,6 +155,9 @@ export default {
143155
return true
144156
}
145157
},
158+
tableProps: {
159+
type: Object
160+
},
146161
actionsDef: {
147162
type: Object,
148163
default() {
@@ -176,6 +191,7 @@ export default {
176191
default: true
177192
},
178193
actionColWidth: String,
194+
actionColFixed: [String, Boolean],
179195
colNotRowClick: {
180196
type: Array,
181197
default() {

0 commit comments

Comments
 (0)