|
14 | 14 | obj = {}, |
15 | 15 | parentId = undefined; |
16 | 16 |
|
17 | | - var compareObjects = function (objectA, objectB, compareLength) { |
18 | | - // Create arrays of property names |
19 | | - var objectAProperties = Object.getOwnPropertyNames(objectA), |
20 | | - objectBProperties = Object.getOwnPropertyNames(objectB), |
21 | | - propName = ''; |
22 | | - |
23 | | - if (compareLength) { |
24 | | - // If number of properties is different, objects are not equivalent |
25 | | - if (objectAProperties.length !== objectBProperties.length) { |
26 | | - return false; |
27 | | - } |
28 | | - } |
29 | | - |
30 | | - for (var i = 0; i < objectAProperties.length; i++) { |
31 | | - propName = objectAProperties[i]; |
32 | | - |
33 | | - // If the property is not in the object B properties, continue with the next property |
34 | | - if ($.inArray(propName, objectBProperties) > -1) { |
35 | | - // If values of same property are not equal, objects are not equivalent |
36 | | - if (objectA[propName] !== objectB[propName]) { |
37 | | - return false; |
38 | | - } |
39 | | - } |
40 | | - } |
41 | | - |
42 | | - // If we made it this far, objects are considered equivalent |
43 | | - return true; |
44 | | - }; |
45 | | - |
46 | | - var getFieldIndex = function (columns, field) { |
47 | | - var index = -1; |
48 | | - |
49 | | - $.each(columns, function (i, column) { |
50 | | - if (column.field === field) { |
51 | | - index = i; |
52 | | - return false; |
53 | | - } |
54 | | - return true; |
55 | | - }); |
56 | | - return index; |
57 | | - }; |
58 | | - |
59 | 17 | var getParentRowId = function (that, id) { |
60 | 18 | var parentRows = that.$body.find('tr').not('[' + 'data-tt-parent-id]'); |
61 | 19 |
|
|
72 | 30 | var sumRow = {}; |
73 | 31 | $.each(data, function (i, row) { |
74 | 32 | if (!row.IsParent) { |
75 | | - for(var prop in row) { |
76 | | - if (!isNaN(parseFloat(row[prop]))) { |
77 | | - if (that.columns[getFieldIndex(that.columns, prop)].groupBySumGroup) { |
78 | | - if (sumRow[prop] === undefined) { |
79 | | - sumRow[prop] = 0; |
80 | | - } |
81 | | - sumRow[prop] += +row[prop]; |
| 33 | + for (var prop in row) { |
| 34 | + if (!isNaN(parseFloat(row[prop]))) { |
| 35 | + if (that.columns[$.fn.bootstrapTable.utils.getFieldIndex(that.columns, prop)].groupBySumGroup) { |
| 36 | + if (sumRow[prop] === undefined) { |
| 37 | + sumRow[prop] = 0; |
82 | 38 | } |
| 39 | + sumRow[prop] += +row[prop]; |
83 | 40 | } |
| 41 | + } |
84 | 42 | } |
85 | 43 | } |
86 | 44 | }); |
|
105 | 63 |
|
106 | 64 | var setObjectKeys = function () { |
107 | 65 | // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys |
108 | | - Object.keys = function (o) { |
109 | | - if (o !== Object(o)) { |
110 | | - throw new TypeError('Object.keys called on a non-object'); |
111 | | - } |
112 | | - var k = [], |
113 | | - p; |
114 | | - for (p in o) { |
115 | | - if (Object.prototype.hasOwnProperty.call(o, p)) { |
116 | | - k.push(p); |
117 | | - } |
118 | | - } |
119 | | - return k; |
120 | | - } |
| 66 | + Object.keys = function (o) { |
| 67 | + if (o !== Object(o)) { |
| 68 | + throw new TypeError('Object.keys called on a non-object'); |
| 69 | + } |
| 70 | + var k = [], |
| 71 | + p; |
| 72 | + for (p in o) { |
| 73 | + if (Object.prototype.hasOwnProperty.call(o, p)) { |
| 74 | + k.push(p); |
| 75 | + } |
| 76 | + } |
| 77 | + return k; |
| 78 | + } |
121 | 79 | }; |
122 | 80 |
|
123 | 81 | var getDataArrayFromItem = function (that, item) { |
|
140 | 98 | return newRow; |
141 | 99 | }; |
142 | 100 |
|
143 | | - var groupBy = function (array , f) { |
144 | | - var groups = {}; |
145 | | - $.each(array, function(i, o) { |
146 | | - var group = JSON.stringify(f(o)); |
147 | | - groups[group] = groups[group] || []; |
148 | | - groups[group].push(o); |
149 | | - }); |
150 | | - return Object.keys(groups).map(function (group) { |
| 101 | + var groupBy = function (array, f) { |
| 102 | + var groups = {}; |
| 103 | + $.each(array, function (i, o) { |
| 104 | + var group = JSON.stringify(f(o)); |
| 105 | + groups[group] = groups[group] || []; |
| 106 | + groups[group].push(o); |
| 107 | + }); |
| 108 | + return Object.keys(groups).map(function (group) { |
151 | 109 | return groups[group]; |
152 | | - }); |
| 110 | + }); |
153 | 111 | }; |
154 | 112 |
|
155 | 113 | var makeGrouped = function (that, data) { |
|
277 | 235 | }; |
278 | 236 |
|
279 | 237 | BootstrapTable.prototype.refreshGroupByField = function (groupByFields) { |
280 | | - if (!compareObjects(this.options.groupByField, groupByFields)) { |
| 238 | + if (!$.fn.bootstrapTable.utils.compareObjects(this.options.groupByField, groupByFields)) { |
281 | 239 | this.options.groupByField = groupByFields; |
282 | 240 | this.load(this.options.originalData); |
283 | 241 | } |
|
0 commit comments