@@ -272,6 +272,8 @@ angular.module('ui.grid')
272272 * @methodOf ui.grid.core.api:PublicApi
273273 * @description adds a row header column to the grid
274274 * @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
275277 *
276278 */
277279 self . api . registerMethod ( 'core' , 'addRowHeaderColumn' , this . addRowHeaderColumn ) ;
@@ -379,7 +381,7 @@ angular.module('ui.grid')
379381 * that have sorting on them, sorted in priority order.
380382 *
381383 * @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
383385 * columns with sorts on them, in priority order.
384386 *
385387 * @example
@@ -754,8 +756,14 @@ angular.module('ui.grid')
754756 * @description adds a row header column to the grid
755757 * @param {object } column def
756758 */
757- Grid . prototype . addRowHeaderColumn = function addRowHeaderColumn ( colDef ) {
759+ Grid . prototype . addRowHeaderColumn = function addRowHeaderColumn ( colDef , order ) {
758760 var self = this ;
761+
762+ //default order
763+ if ( order === undefined ) {
764+ order = 0 ;
765+ }
766+
759767 var rowHeaderCol = new GridColumn ( colDef , gridUtil . nextUid ( ) , self ) ;
760768 rowHeaderCol . isRowHeader = true ;
761769 if ( self . isRTL ( ) ) {
@@ -774,7 +782,12 @@ angular.module('ui.grid')
774782 rowHeaderCol . enableFiltering = false ;
775783 rowHeaderCol . enableSorting = false ;
776784 rowHeaderCol . enableHiding = false ;
785+ rowHeaderCol . headerPriority = order ;
777786 self . rowHeaderColumns . push ( rowHeaderCol ) ;
787+ self . rowHeaderColumns = self . rowHeaderColumns . sort ( function ( a , b ) {
788+ return a . headerPriority - b . headerPriority ;
789+ } ) ;
790+
778791 self . buildColumns ( )
779792 . then ( function ( ) {
780793 self . preCompileCellTemplates ( ) ;
@@ -836,9 +849,11 @@ angular.module('ui.grid')
836849 }
837850
838851 //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+
842857
843858
844859 // look at each column def, and update column properties to match. If the column def
@@ -898,6 +913,19 @@ angular.module('ui.grid')
898913 } ) ;
899914 } ;
900915
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+
901929/**
902930 * @ngdoc function
903931 * @name preCompileCellTemplates
@@ -906,25 +934,12 @@ angular.module('ui.grid')
906934 */
907935 Grid . prototype . preCompileCellTemplates = function ( ) {
908936 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 ) {
923938 if ( col . cellTemplate ) {
924- preCompileTemplate ( col ) ;
939+ self . preCompileCellTemplate ( col ) ;
925940 } else if ( col . cellTemplatePromise ) {
926941 col . cellTemplatePromise . then ( function ( ) {
927- preCompileTemplate ( col ) ;
942+ self . preCompileCellTemplate ( col ) ;
928943 } ) ;
929944 }
930945 } ) ;
0 commit comments