Commit c13e7cea814d5496357a4cff456edf1f77f99bda
1 parent
3fd97880
Table add check & highlight default setting in data
Table add check & highlight default setting in data #275 #265
Showing
3 changed files
with
26 additions
and
8 deletions
Show diff stats
package.json
| 1 | { | 1 | { |
| 2 | "name": "iview", | 2 | "name": "iview", |
| 3 | - "version": "0.9.17", | 3 | + "version": "1.0.0", |
| 4 | "title": "iView", | 4 | "title": "iView", |
| 5 | "description": "A high quality UI components Library with Vue.js", | 5 | "description": "A high quality UI components Library with Vue.js", |
| 6 | "homepage": "http://www.iviewui.com", | 6 | "homepage": "http://www.iviewui.com", |
src/components/table/table.vue
| @@ -548,8 +548,16 @@ | @@ -548,8 +548,16 @@ | ||
| 548 | this.data.forEach((row, index) => { | 548 | this.data.forEach((row, index) => { |
| 549 | const newRow = deepCopy(row);// todo 直接替换 | 549 | const newRow = deepCopy(row);// todo 直接替换 |
| 550 | newRow._isHover = false; | 550 | newRow._isHover = false; |
| 551 | - newRow._isChecked = false; | ||
| 552 | - newRow._isHighlight = false; | 551 | + if (newRow._checked) { |
| 552 | + newRow._isChecked = newRow._checked; | ||
| 553 | + } else { | ||
| 554 | + newRow._isChecked = false; | ||
| 555 | + } | ||
| 556 | + if (newRow._highlight) { | ||
| 557 | + newRow._isHighlight = newRow._highlight; | ||
| 558 | + } else { | ||
| 559 | + newRow._isHighlight = false; | ||
| 560 | + } | ||
| 553 | data[index] = newRow; | 561 | data[index] = newRow; |
| 554 | }); | 562 | }); |
| 555 | return data; | 563 | return data; |
test/routers/table.vue
| 1 | <template> | 1 | <template> |
| 2 | - <i-table border :content="self" :columns="columns7" :data="data6"></i-table> | 2 | + <i-table highlight-row border :content="self" :columns="columns7" :data="data6"></i-table> |
| 3 | </template> | 3 | </template> |
| 4 | <script> | 4 | <script> |
| 5 | export default { | 5 | export default { |
| @@ -8,6 +8,11 @@ | @@ -8,6 +8,11 @@ | ||
| 8 | self: this, | 8 | self: this, |
| 9 | columns7: [ | 9 | columns7: [ |
| 10 | { | 10 | { |
| 11 | + type: 'selection', | ||
| 12 | + width: 60, | ||
| 13 | + align: 'center' | ||
| 14 | + }, | ||
| 15 | + { | ||
| 11 | title: '姓名', | 16 | title: '姓名', |
| 12 | key: 'name', | 17 | key: 'name', |
| 13 | render (row, column, index) { | 18 | render (row, column, index) { |
| @@ -47,22 +52,27 @@ | @@ -47,22 +52,27 @@ | ||
| 47 | { | 52 | { |
| 48 | name: '王小明', | 53 | name: '王小明', |
| 49 | age: 18, | 54 | age: 18, |
| 50 | - address: '北京市朝阳区芍药居' | 55 | + address: '北京市朝阳区芍药居', |
| 56 | + _highlight: true, | ||
| 57 | + _checked: true | ||
| 51 | }, | 58 | }, |
| 52 | { | 59 | { |
| 53 | name: '张小刚', | 60 | name: '张小刚', |
| 54 | age: 25, | 61 | age: 25, |
| 55 | - address: '北京市海淀区西二旗' | 62 | + address: '北京市海淀区西二旗', |
| 63 | + _checked: true | ||
| 56 | }, | 64 | }, |
| 57 | { | 65 | { |
| 58 | name: '李小红', | 66 | name: '李小红', |
| 59 | age: 30, | 67 | age: 30, |
| 60 | - address: '上海市浦东新区世纪大道' | 68 | + address: '上海市浦东新区世纪大道', |
| 69 | + _checked: true | ||
| 61 | }, | 70 | }, |
| 62 | { | 71 | { |
| 63 | name: '周小伟', | 72 | name: '周小伟', |
| 64 | age: 26, | 73 | age: 26, |
| 65 | - address: '深圳市南山区深南大道' | 74 | + address: '深圳市南山区深南大道', |
| 75 | + _checked: true | ||
| 66 | } | 76 | } |
| 67 | ] | 77 | ] |
| 68 | } | 78 | } |