Blame view

examples/routers/table.vue 8.49 KB
2cb8a6d9   梁灏   commit Table comp...
1
  <template>
bb49347b   梁灏   fixed #2823
2
      <div>
14d1de05   huanghong   fix table changin...
3
          <Table border ref="selection" :columns="columns4" :data="data1" :height='258'></Table>
bb49347b   梁灏   fixed #2823
4
5
6
7
          <Button @click="handleSetData">Set Data</Button>
          <Button @click="handleClearData">Clear Data</Button>
          <Button @click="handleSelectAll(true)">Set all selected</Button>
          <Button @click="handleSelectAll(false)">Cancel all selected</Button>
9fea8e7d   huanghong   fixed ivu-table-f...
8
9
10
11
12
13
          <div style='margin:20px 0px'>
              <Table border :columns="columns2" :data="data3"></Table>
          </div>
          <div style='margin:20px 0px'>
              <Table :height='200' border :columns="columns2" :data="data3"></Table>
          </div>
95e1720c   huanghong   fix ivu-table-fix...
14
15
16
17
18
19
          <div style='margin:20px 0px'>
              <Table  :width='500' border :columns="columns2" :data="data3"></Table>
          </div>
          <div style='margin:20px 0px'>
              <Table  :width='500' :height='200' border :columns="columns2" :data="data3"></Table>
          </div>
ebaf3c1d   huanghong   table test
20
          <div style='margin:20px 0px;'>
b08bd8a8   huanghong   fixed height changed
21
22
              Table scrolling <i-switch v-model="fixedHeader" style="margin-right: 5px"></i-switch>
              <Table :data="tableData1" :columns="tableColumns1" :height="fixedHeader ? 250 : ''" stripe size='small'></Table>
944c0dac   huanghong   add example for d...
23
24
25
26
27
28
              <div style="margin: 10px;overflow: hidden">
                  <div style="float: right;">
                      <Page :total="100" show-sizer :current="1" @on-change="changePage"></Page>
                  </div>
              </div>
          </div>
9fea8e7d   huanghong   fixed ivu-table-f...
29
  
bb49347b   梁灏   fixed #2823
30
      </div>
2cb8a6d9   梁灏   commit Table comp...
31
32
  </template>
  <script>
2cb8a6d9   梁灏   commit Table comp...
33
      export default {
51356c2c   梁灏   fixed #658
34
35
          data () {
              return {
bb49347b   梁灏   fixed #2823
36
                  columns4: [
ceeb9361   梁灏   fixed Table bug i...
37
                      {
bb49347b   梁灏   fixed #2823
38
39
40
                          type: 'selection',
                          width: 60,
                          align: 'center'
ceeb9361   梁灏   fixed Table bug i...
41
                      },
437b8059   Sergio Crisostomo   Added Table to CS...
42
                      {
55f90d87   梁灏   fixed #1648
43
                          title: 'Name',
14d1de05   huanghong   fix table changin...
44
45
                          key: 'name',
                          width: 260
2993f4ee   梁灏   update Tab
46
47
                      },
                      {
55f90d87   梁灏   fixed #1648
48
                          title: 'Age',
bb49347b   梁灏   fixed #2823
49
                          key: 'age'
2993f4ee   梁灏   update Tab
50
51
                      },
                      {
55f90d87   梁灏   fixed #1648
52
                          title: 'Address',
14d1de05   huanghong   fix table changin...
53
54
55
56
57
58
59
                          key: 'address',
                          width: 260
                      },
                      {
                          title: 'Address',
                          key: 'address',
                          width: 260
437b8059   Sergio Crisostomo   Added Table to CS...
60
61
                      }
                  ],
bb49347b   梁灏   fixed #2823
62
63
                  data1: [
  
944c0dac   huanghong   add example for d...
64
                  ],
9fea8e7d   huanghong   fixed ivu-table-f...
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
                  columns2: [
                      {
                          title: 'Name',
                          key: 'name',
                          width: 100,
                          fixed: 'left'
                      },
                      {
                          title: 'Age',
                          key: 'age',
                          width: 100
                      },
                      {
                          title: 'Province',
                          key: 'province',
                          width: 100
                      },
                      {
                          title: 'City',
                          key: 'city',
                          width: 100
                      },
                      {
                          title: 'Address',
                          key: 'address',
                          width: 200
                      },
                      {
                          title: 'Postcode',
                          key: 'zip',
                          width: 100
                      },
                      {
                          title: 'Action',
                          key: 'action',
                          fixed: 'right',
                          width: 120,
                          render: (h, params) => {
                              return h('div', [
                                  h('Button', {
                                      props: {
                                          type: 'text',
                                          size: 'small'
                                      }
                                  }, 'View'),
                                  h('Button', {
                                      props: {
                                          type: 'text',
                                          size: 'small'
                                      }
                                  }, 'Edit')
                              ]);
                          }
                      }
                  ],
                  data3: [
                      {
                          name: 'John Brown',
                          age: 18,
                          address: 'New York No. 1 Lake Park',
                          province: 'America',
                          city: 'New York',
                          zip: 100000
                      },
                      {
                          name: 'Jim Green',
                          age: 24,
                          address: 'Washington, D.C. No. 1 Lake Park',
                          province: 'America',
                          city: 'Washington, D.C.',
                          zip: 100000
                      },
                      {
                          name: 'Joe Black',
                          age: 30,
                          address: 'Sydney No. 1 Lake Park',
                          province: 'Australian',
                          city: 'Sydney',
                          zip: 100000
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
                          province: 'Canada',
                          city: 'Ottawa',
                          zip: 100000
                      }
                  ],
944c0dac   huanghong   add example for d...
154
                  
b08bd8a8   huanghong   fixed height changed
155
                  fixedHeader: false,
944c0dac   huanghong   add example for d...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
                  tableData1: [],
                  tableColumns1: [
                      {
                          title: 'Data1',
                          key: 'data1'
                      },
                      {
                          title: 'Data2',
                          key: 'data2'
                      },
                      {
                          title: 'Data3',
                          key: 'data3'
                      },
                      {
                          title: 'Data4',
                          key: 'data4'
                      },
                      {
                          title: 'Data5',
                          key: 'data5'
                      },
                      {
ebaf3c1d   huanghong   table test
179
                          title: 'Data6Data6Data6Data6Data6Data6Data6Data6Data6Data6Data6',
944c0dac   huanghong   add example for d...
180
181
                          key: 'data6'
                      },
bb49347b   梁灏   fixed #2823
182
183
184
                  ]
              }
          },
944c0dac   huanghong   add example for d...
185
186
187
          mounted(){
              this.refreshData();
          },
bb49347b   梁灏   fixed #2823
188
189
190
191
192
193
          methods: {
              handleSelectAll (status) {
                  this.$refs.selection.selectAll(status);
              },
              handleSetData () {
                  this.data1 = [
b142865e   梁灏   fixed #2102
194
195
196
197
                      {
                          name: 'John Brown',
                          age: 18,
                          address: 'New York No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
198
                          date: '2016-10-03'
b142865e   梁灏   fixed #2102
199
200
201
202
                      },
                      {
                          name: 'Jim Green',
                          age: 24,
ceeb9361   梁灏   fixed Table bug i...
203
204
                          address: 'London No. 1 Lake Park',
                          date: '2016-10-01'
b142865e   梁灏   fixed #2102
205
206
207
208
209
                      },
                      {
                          name: 'Joe Black',
                          age: 30,
                          address: 'Sydney No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
210
                          date: '2016-10-02'
b142865e   梁灏   fixed #2102
211
212
213
214
215
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
216
                          date: '2016-10-04'
437b8059   Sergio Crisostomo   Added Table to CS...
217
                      }
bb49347b   梁灏   fixed #2823
218
219
220
221
                  ];
              },
              handleClearData () {
                  this.data1 = [];
944c0dac   huanghong   add example for d...
222
223
224
225
226
227
228
229
230
231
              },
              refreshData(){
                  let data = [];
                  for (let i = 0; i < 10; i++) {
                      data.push({
                          data1: Math.floor(Math.random () * 10000),
                          data2: Math.floor(Math.random () * 1000000),
                          data3: Math.floor(Math.random () * 100000000),
                          data4: Math.floor(Math.random () * Math.random () * 10000),
                          data5: Math.floor(Math.random () * Math.random () * 1000000),
47638ad8   huanghong   fixed table scrol...
232
                          data6: ''+Math.floor(Math.random () * Math.random () * 100000000)+Math.floor(Math.random () * 100000000)+Math.floor(Math.random () * 100000000),
944c0dac   huanghong   add example for d...
233
234
235
236
237
238
                      });
                  }
                  this.tableData1 = data;
              },
              changePage(){
                  this.refreshData();
c5beedf8   梁灏   fixed #690
239
              }
2cb8a6d9   梁灏   commit Table comp...
240
          }
6c634aa6   梁灏   fixed #2078
241
      }
17db7df4   梁灏   fixed #1751
242
  </script>