Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
104 lines (95 loc) · 2.75 KB
/
Copy pathapp.js
File metadata and controls
104 lines (95 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
// http://wenzhixin.net.cn/p/bootstrap-table/docs/getting-started.html
window.angular.module('app', ['bsTable'])
.controller('MainController', function ($scope, $http) {
$scope.workspaces = []
$scope.workspaces.push({ name: 'Workspace 1' })
$scope.workspaces.push({ name: 'Workspace 2' })
$scope.workspaces.push({ name: 'Workspace 3' })
function makeRandomRows (colData) {
var rows = []
for (var i = 0; i < 500; i++) {
rows.push($.extend({
index: i,
id: 'row ' + i,
name: 'GOOG' + i,
flagImage: Math.random() < 0.4
? 'img/blueFlag16.png'
: Math.random() < 0.75
? 'img/yellowFlag16.png'
: 'img/greenFlag16.png'
}, colData))
}
return rows
}
function flagFormatter(value, row, index) {
return '<img src="' + row.flagImage + '"/>'
}
$scope.workspaces.forEach(function (wk,index) {
var colData = {workspace: wk.name}
wk.rows = makeRandomRows(colData)
wk.bsTableControl = {
options: {
data: wk.rows,
rowStyle: function (row, index) {
return { classes: 'none' }
},
cache: false,
height: 400,
pagination: true,
pageSize: 10,
pageList: [5, 10, 25, 50, 100, 200],
search: true,
showColumns: true,
showRefresh: false,
minimumCountColumns: 2,
clickToSelect: false,
showToggle: true,
maintainSelected: true,
columns: [{
field: 'state',
checkbox: true
}, {
field: 'index',
title: '#',
align: 'right',
valign: 'bottom',
sortable: true
}, {
field: 'id',
title: 'Item ID',
align: 'center',
valign: 'bottom',
sortable: true
}, {
field: 'name',
title: 'Item Name',
align: 'center',
valign: 'middle',
sortable: true
}, {
field: 'workspace',
title: 'Workspace',
align: 'left',
valign: 'top',
sortable: true
}, {
field: 'flag',
title: 'Flag',
align: 'center',
valign: 'middle',
clickToSelect: false,
formatter: flagFormatter
// events: flagEvents
}]
}
}
})
$scope.changeCurrentWorkspace = function (wk) {
$scope.currentWorkspace = wk
}
// Select the workspace in document ready event
$(document).ready(function () {
$scope.changeCurrentWorkspace($scope.workspaces[0])
$scope.$apply()
})
})