File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1235,6 +1235,9 @@ angular.module('ui.grid')
1235
1235
if ( oldRow ) {
1236
1236
newRow = oldRow ;
1237
1237
newRow . entity = newEntity ;
1238
+ if ( newRow . index !== i ) {
1239
+ newRow . index = i ;
1240
+ }
1238
1241
}
1239
1242
1240
1243
// if we didn't find the row, it must be new, so create it
Original file line number Diff line number Diff line change @@ -731,6 +731,18 @@ describe('Grid factory', function() {
731
731
expect ( grid . rows [ 1 ] . entity . str ) . toBe ( 'xyz' ) ;
732
732
expect ( grid . rows [ 2 ] . entity . str ) . toBe ( 'bac' ) ;
733
733
} ) ;
734
+
735
+ it ( 'should delete and insert new in the middle' , function ( ) {
736
+ dataRows . splice ( 2 , 0 , { str : 'wwe' } ) ;
737
+ grid . modifyRows ( dataRows ) ;
738
+
739
+ expect ( grid . getRow ) . not . toHaveBeenCalled ( ) ;
740
+ expect ( grid . rows . length ) . toBe ( 4 ) ;
741
+ expect ( grid . rows [ 0 ] . index ) . toBe ( 0 ) ;
742
+ expect ( grid . rows [ 2 ] . entity . str ) . toBe ( 'wwe' ) ;
743
+ expect ( grid . rows [ 3 ] . entity . str ) . toBe ( 'bac' ) ;
744
+ expect ( grid . rows [ 3 ] . index ) . toBe ( 3 ) ;
745
+ } ) ;
734
746
} ) ;
735
747
736
748
describe ( 'binding' , function ( ) {
You can’t perform that action at this time.
0 commit comments