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
src/components/table/table.vue
| ... | ... | @@ -548,8 +548,16 @@ |
| 548 | 548 | this.data.forEach((row, index) => { |
| 549 | 549 | const newRow = deepCopy(row);// todo 直接替换 |
| 550 | 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 | 561 | data[index] = newRow; |
| 554 | 562 | }); |
| 555 | 563 | return data; | ... | ... |
test/routers/table.vue
| 1 | 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 | 3 | </template> |
| 4 | 4 | <script> |
| 5 | 5 | export default { |
| ... | ... | @@ -8,6 +8,11 @@ |
| 8 | 8 | self: this, |
| 9 | 9 | columns7: [ |
| 10 | 10 | { |
| 11 | + type: 'selection', | |
| 12 | + width: 60, | |
| 13 | + align: 'center' | |
| 14 | + }, | |
| 15 | + { | |
| 11 | 16 | title: '姓名', |
| 12 | 17 | key: 'name', |
| 13 | 18 | render (row, column, index) { |
| ... | ... | @@ -47,22 +52,27 @@ |
| 47 | 52 | { |
| 48 | 53 | name: '王小明', |
| 49 | 54 | age: 18, |
| 50 | - address: '北京市朝阳区芍药居' | |
| 55 | + address: '北京市朝阳区芍药居', | |
| 56 | + _highlight: true, | |
| 57 | + _checked: true | |
| 51 | 58 | }, |
| 52 | 59 | { |
| 53 | 60 | name: '张小刚', |
| 54 | 61 | age: 25, |
| 55 | - address: '北京市海淀区西二旗' | |
| 62 | + address: '北京市海淀区西二旗', | |
| 63 | + _checked: true | |
| 56 | 64 | }, |
| 57 | 65 | { |
| 58 | 66 | name: '李小红', |
| 59 | 67 | age: 30, |
| 60 | - address: '上海市浦东新区世纪大道' | |
| 68 | + address: '上海市浦东新区世纪大道', | |
| 69 | + _checked: true | |
| 61 | 70 | }, |
| 62 | 71 | { |
| 63 | 72 | name: '周小伟', |
| 64 | 73 | age: 26, |
| 65 | - address: '深圳市南山区深南大道' | |
| 74 | + address: '深圳市南山区深南大道', | |
| 75 | + _checked: true | |
| 66 | 76 | } |
| 67 | 77 | ] |
| 68 | 78 | } | ... | ... |