@@ -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
} ) ;
0 commit comments