|
93 | 93 |
|
94 | 94 | column.drawnWidth = column.width;
|
95 | 95 |
|
96 |
| - ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + column.width + 'px; }'; |
| 96 | + // ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + column.width + 'px; }'; |
97 | 97 | }
|
98 | 98 | });
|
99 | 99 |
|
|
119 | 119 | canvasWidth += colWidth;
|
120 | 120 | column.drawnWidth = colWidth;
|
121 | 121 |
|
122 |
| - ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + colWidth + 'px; }'; |
| 122 | + // ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + colWidth + 'px; }'; |
123 | 123 |
|
124 | 124 | // Remove this element from the percent array so it's not processed below
|
125 | 125 | percentArray.splice(i, 1);
|
|
132 | 132 | canvasWidth += colWidth;
|
133 | 133 | column.drawnWidth = colWidth;
|
134 | 134 |
|
135 |
| - ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + colWidth + 'px; }'; |
| 135 | + // ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + colWidth + 'px; }'; |
136 | 136 |
|
137 | 137 | // Remove this element from the percent array so it's not processed below
|
138 | 138 | percentArray.splice(i, 1);
|
|
147 | 147 |
|
148 | 148 | column.drawnWidth = colWidth;
|
149 | 149 |
|
150 |
| - ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + colWidth + 'px; }'; |
| 150 | + // ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + colWidth + 'px; }'; |
151 | 151 | });
|
152 | 152 | }
|
153 | 153 |
|
|
169 | 169 | canvasWidth += colWidth;
|
170 | 170 | column.drawnWidth = colWidth;
|
171 | 171 |
|
172 |
| - ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + colWidth + 'px; }'; |
| 172 | + // ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + colWidth + 'px; }'; |
173 | 173 |
|
174 | 174 | lastColumn = column;
|
175 | 175 |
|
|
185 | 185 | canvasWidth += colWidth;
|
186 | 186 | column.drawnWidth = colWidth;
|
187 | 187 |
|
188 |
| - ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + colWidth + 'px; }'; |
| 188 | + // ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + colWidth + 'px; }'; |
189 | 189 |
|
190 | 190 | // Remove this element from the percent array so it's not processed below
|
191 | 191 | asterisksArray.splice(i, 1);
|
|
202 | 202 |
|
203 | 203 | column.drawnWidth = colWidth;
|
204 | 204 |
|
205 |
| - ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + colWidth + 'px; }'; |
| 205 | + // ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + colWidth + 'px; }'; |
206 | 206 | });
|
207 | 207 | }
|
208 | 208 |
|
| 209 | + |
| 210 | + // If the grid width didn't divide evenly into the column widths and we have pixels left over, dole them out to the columns one by one to make everything fit |
| 211 | + var leftoverWidth = uiGridCtrl.grid.gridWidth - parseInt(canvasWidth, 10); |
| 212 | + |
| 213 | + if (leftoverWidth > 0 && canvasWidth > 0) { |
| 214 | + var remFn = function (column) { |
| 215 | + if (leftoverWidth > 0) { |
| 216 | + column.drawnWidth = column.drawnWidth + 1; |
| 217 | + canvasWidth = canvasWidth + 1; |
| 218 | + leftoverWidth--; |
| 219 | + } |
| 220 | + }; |
| 221 | + while (leftoverWidth > 0) { |
| 222 | + uiGridCtrl.grid.columns.forEach(remFn); |
| 223 | + } |
| 224 | + } |
| 225 | + |
| 226 | + // Build the CSS |
| 227 | + uiGridCtrl.grid.columns.forEach(function (column) { |
| 228 | + ret = ret + ' .grid' + uiGridCtrl.grid.id + ' .col' + column.index + ' { width: ' + column.drawnWidth + 'px; }'; |
| 229 | + }); |
| 230 | + |
209 | 231 | $scope.columnStyles = ret;
|
210 | 232 |
|
211 | 233 | uiGridCtrl.grid.canvasWidth = parseInt(canvasWidth, 10);
|
|
0 commit comments