|
36 | 36 |
|
37 | 37 | <script> |
38 | 38 | import VueBootstrap4Table from './components/VueBootstrap4Table.vue' |
39 | | -
|
| 39 | + var chance = require('chance').Chance(88); |
40 | 40 | export default { |
41 | 41 | name: 'App', |
42 | 42 | data: function() { |
|
109 | 109 | row_classes: "my-row-class1 my-row-class2", |
110 | 110 | column_classes: "my-column-class1 my-column-class2" |
111 | 111 | }, |
| 112 | + { |
| 113 | + label: "Salary", |
| 114 | + name: "salary", |
| 115 | + // filter: { |
| 116 | + // type: "simple", |
| 117 | + // placeholder: "Enter email" |
| 118 | + // }, |
| 119 | + sort: true, |
| 120 | + row_text_alignment: "text-left", |
| 121 | + column_text_alignment: "text-left" |
| 122 | + }, |
112 | 123 | { |
113 | 124 | label: "City", |
114 | 125 | name: "address.city", |
|
147 | 158 | selected_rows_info: true |
148 | 159 | }, |
149 | 160 | classes: { |
150 | | - // table : { |
151 | | - // "table-striped my-class" : true, |
152 | | - // "table-bordered my-class-two" : function(rows) { |
153 | | - // return true |
154 | | - // } |
155 | | - // } |
| 161 | + table : { |
| 162 | + "table-striped my-class" : true, |
| 163 | + "table-bordered my-class-two" : function(rows) { |
| 164 | + return true |
| 165 | + } |
| 166 | + }, |
| 167 | + row : { |
| 168 | + "my-row my-row2" : true, |
| 169 | + "function-class" : function(row) { |
| 170 | + return row.id == 1 |
| 171 | + } |
| 172 | + }, |
| 173 | + cell : { |
| 174 | + "my-cell my-cell2" : true, |
| 175 | + "text-danger" : function(row,column,cellValue) { |
| 176 | + return column.name == "salary" && row.salary > 2500 |
| 177 | + } |
| 178 | + }, |
156 | 179 | // table : "table-striped table-bordered my-class", |
157 | | -
|
158 | 180 | }, |
159 | 181 | // actions: [] |
160 | 182 | actions: [ |
|
177 | 199 | }, |
178 | 200 | methods: { |
179 | 201 | fetchData() { |
180 | | - let self = this; |
181 | | - axios.get('https://raw.githubusercontent.com/rubanraj54/vue-bootstrap4-table/develop/src/assets/toy_data/users_500.json') |
182 | | - .then(function(response) { |
183 | | - self.rows = response.data; |
184 | | - }) |
185 | | - .catch(function(error) { |
186 | | - console.log(error); |
187 | | - }); |
| 202 | + let user; |
| 203 | + let users = []; |
| 204 | + for (let i = 1; i <=500; i++) { |
| 205 | + user = { |
| 206 | + id : i, |
| 207 | + name: { |
| 208 | + first_name: chance.first(), |
| 209 | + last_name: chance.last(), |
| 210 | + }, |
| 211 | + age: chance.age(), |
| 212 | + address: { |
| 213 | + city: chance.city(), |
| 214 | + street: chance.address(), |
| 215 | + postcode: chance.postcode(), |
| 216 | + country: chance.country({ full: true }) |
| 217 | + }, |
| 218 | + salary: chance.integer({ min: 1500, max: 3000 }), |
| 219 | + email: chance.email(), |
| 220 | + website: chance.domain(), |
| 221 | + mobile: chance.phone() |
| 222 | + } |
| 223 | + users.push(user); |
| 224 | + } |
| 225 | + this.rows = users; |
188 | 226 | }, |
189 | 227 | onSelectRows(payload) { |
190 | 228 | console.log(payload); |
|
256 | 294 | mounted() { |
257 | 295 | let self = this; |
258 | 296 | this.fetchData(); |
259 | | -
|
260 | 297 | // let test = [1,2,3,4,5,6,7] |
261 | 298 |
|
262 | 299 | // test.some((val,index) => { |
|
0 commit comments