@@ -272,6 +272,8 @@ angular.module('ui.grid')
272
272
* @methodOf ui.grid.core.api:PublicApi
273
273
* @description adds a row header column to the grid
274
274
* @param {object } column def
275
+ * @param {number } order Determines order of header column on grid. Lower order means header
276
+ * is positioned to the left of higher order headers
275
277
*
276
278
*/
277
279
self . api . registerMethod ( 'core' , 'addRowHeaderColumn' , this . addRowHeaderColumn ) ;
@@ -379,7 +381,7 @@ angular.module('ui.grid')
379
381
* that have sorting on them, sorted in priority order.
380
382
*
381
383
* @param {$scope } scope The scope of the controller. This is used to deregister this event when the scope is destroyed.
382
- * @param {Function } callBack Will be called when the event is emited. The function passes back the grid and an array of
384
+ * @param {Function } callBack Will be called when the event is emited. The function passes back the grid and an array of
383
385
* columns with sorts on them, in priority order.
384
386
*
385
387
* @example
@@ -754,8 +756,14 @@ angular.module('ui.grid')
754
756
* @description adds a row header column to the grid
755
757
* @param {object } column def
756
758
*/
757
- Grid . prototype . addRowHeaderColumn = function addRowHeaderColumn ( colDef ) {
759
+ Grid . prototype . addRowHeaderColumn = function addRowHeaderColumn ( colDef , order ) {
758
760
var self = this ;
761
+
762
+ //default order
763
+ if ( order === undefined ) {
764
+ order = 0 ;
765
+ }
766
+
759
767
var rowHeaderCol = new GridColumn ( colDef , gridUtil . nextUid ( ) , self ) ;
760
768
rowHeaderCol . isRowHeader = true ;
761
769
if ( self . isRTL ( ) ) {
@@ -774,7 +782,12 @@ angular.module('ui.grid')
774
782
rowHeaderCol . enableFiltering = false ;
775
783
rowHeaderCol . enableSorting = false ;
776
784
rowHeaderCol . enableHiding = false ;
785
+ rowHeaderCol . headerPriority = order ;
777
786
self . rowHeaderColumns . push ( rowHeaderCol ) ;
787
+ self . rowHeaderColumns = self . rowHeaderColumns . sort ( function ( a , b ) {
788
+ return a . headerPriority - b . headerPriority ;
789
+ } ) ;
790
+
778
791
self . buildColumns ( )
779
792
. then ( function ( ) {
780
793
self . preCompileCellTemplates ( ) ;
@@ -836,9 +849,11 @@ angular.module('ui.grid')
836
849
}
837
850
838
851
//add row header columns to the grid columns array _after_ columns without columnDefs have been removed
839
- self . rowHeaderColumns . forEach ( function ( rowHeaderColumn ) {
840
- self . columns . unshift ( rowHeaderColumn ) ;
841
- } ) ;
852
+ //rowHeaderColumns is ordered by priority so insert in reverse
853
+ for ( var j = self . rowHeaderColumns . length - 1 ; j >= 0 ; j -- ) {
854
+ self . columns . unshift ( self . rowHeaderColumns [ j ] ) ;
855
+ }
856
+
842
857
843
858
844
859
// look at each column def, and update column properties to match. If the column def
@@ -898,6 +913,19 @@ angular.module('ui.grid')
898
913
} ) ;
899
914
} ;
900
915
916
+ Grid . prototype . preCompileCellTemplate = function ( col ) {
917
+ var self = this ;
918
+ var html = col . cellTemplate . replace ( uiGridConstants . MODEL_COL_FIELD , self . getQualifiedColField ( col ) ) ;
919
+ html = html . replace ( uiGridConstants . COL_FIELD , 'grid.getCellValue(row, col)' ) ;
920
+
921
+ var compiledElementFn = $compile ( html ) ;
922
+ col . compiledElementFn = compiledElementFn ;
923
+
924
+ if ( col . compiledElementFnDefer ) {
925
+ col . compiledElementFnDefer . resolve ( col . compiledElementFn ) ;
926
+ }
927
+ } ;
928
+
901
929
/**
902
930
* @ngdoc function
903
931
* @name preCompileCellTemplates
@@ -906,25 +934,12 @@ angular.module('ui.grid')
906
934
*/
907
935
Grid . prototype . preCompileCellTemplates = function ( ) {
908
936
var self = this ;
909
-
910
- var preCompileTemplate = function ( col ) {
911
- var html = col . cellTemplate . replace ( uiGridConstants . MODEL_COL_FIELD , self . getQualifiedColField ( col ) ) ;
912
- html = html . replace ( uiGridConstants . COL_FIELD , 'grid.getCellValue(row, col)' ) ;
913
-
914
- var compiledElementFn = $compile ( html ) ;
915
- col . compiledElementFn = compiledElementFn ;
916
-
917
- if ( col . compiledElementFnDefer ) {
918
- col . compiledElementFnDefer . resolve ( col . compiledElementFn ) ;
919
- }
920
- } ;
921
-
922
- this . columns . forEach ( function ( col ) {
937
+ self . columns . forEach ( function ( col ) {
923
938
if ( col . cellTemplate ) {
924
- preCompileTemplate ( col ) ;
939
+ self . preCompileCellTemplate ( col ) ;
925
940
} else if ( col . cellTemplatePromise ) {
926
941
col . cellTemplatePromise . then ( function ( ) {
927
- preCompileTemplate ( col ) ;
942
+ self . preCompileCellTemplate ( col ) ;
928
943
} ) ;
929
944
}
930
945
} ) ;
@@ -2363,18 +2378,13 @@ angular.module('ui.grid')
2363
2378
2364
2379
// We were given a column to scroll to
2365
2380
if ( gridCol !== null ) {
2366
- // This is the index of the row we want to scroll to, within the list of rows that can be visible
2381
+ // This is the index of the column we want to scroll to, within the list of columns that can be visible
2367
2382
var seekColumnIndex = visColCache . indexOf ( gridCol ) ;
2368
2383
2369
- // Total vertical scroll length of the grid
2384
+ // Total horizontal scroll length of the grid
2370
2385
var horizScrollLength = ( self . renderContainers . body . getCanvasWidth ( ) - self . renderContainers . body . getViewportWidth ( ) ) ;
2371
2386
2372
- // Add the height of the native horizontal scrollbar to the scroll length, if it's there. Otherwise it will mask over the final row
2373
- // if (self.verticalScrollbarWidth && self.verticalScrollbarWidth > 0) {
2374
- // horizScrollLength = horizScrollLength + self.verticalScrollbarWidth;
2375
- // }
2376
-
2377
- // This is the minimum amount of pixels we need to scroll vertical in order to see this column
2387
+ // This is the minimum amount of pixels we need to scroll horizontal in order to see this column
2378
2388
var columnLeftEdge = 0 ;
2379
2389
for ( var i = 0 ; i < seekColumnIndex ; i ++ ) {
2380
2390
var col = visColCache [ i ] ;
@@ -2389,9 +2399,9 @@ angular.module('ui.grid')
2389
2399
2390
2400
var horizScrollPixels , horizPercentage ;
2391
2401
2392
- // If the scroll position we need to see the row is LESS than the top boundary, i.e. obscured above the top of the self...
2402
+ // If the scroll position we need to see the column is LESS than the left boundary, i.e. obscured before the left of the self...
2393
2403
if ( columnLeftEdge < leftBound ) {
2394
- // Get the different between the top boundary and the required scroll position and subtract it from the current scroll position\
2404
+ // Get the different between the left boundary and the required scroll position and subtract it from the current scroll position\
2395
2405
// to get the full position we need
2396
2406
horizScrollPixels = self . renderContainers . body . prevScrollLeft - ( leftBound - columnLeftEdge ) ;
2397
2407
@@ -2400,9 +2410,9 @@ angular.module('ui.grid')
2400
2410
horizPercentage = ( horizPercentage > 1 ) ? 1 : horizPercentage ;
2401
2411
scrollEvent . x = { percentage : horizPercentage } ;
2402
2412
}
2403
- // Otherwise if the scroll position we need to see the row is MORE than the bottom boundary, i.e. obscured below the bottom of the self...
2413
+ // Otherwise if the scroll position we need to see the column is MORE than the right boundary, i.e. obscured after the right of the self...
2404
2414
else if ( columnRightEdge > rightBound ) {
2405
- // Get the different between the bottom boundary and the required scroll position and add it to the current scroll position
2415
+ // Get the different between the right boundary and the required scroll position and add it to the current scroll position
2406
2416
// to get the full position we need
2407
2417
horizScrollPixels = columnRightEdge - rightBound + self . renderContainers . body . prevScrollLeft ;
2408
2418
0 commit comments