@@ -394,6 +394,25 @@ export function main() {
394394 } ) ;
395395 } ) ;
396396
397+ it ( "should detect changes when original data source is changed but the data source length is the same." , ( done ) => {
398+ var template = "<ig-grid [widgetId]='gridID' [(options)]='optsNew'></ig-grid>" ;
399+ TestBed . overrideComponent ( TestComponent , {
400+ set : {
401+ template : template
402+ }
403+ } ) ;
404+ TestBed . compileComponents ( ) . then ( ( ) => {
405+ var fixture = TestBed . createComponent ( TestComponent ) ;
406+ fixture . componentInstance . singleRecData . length = 0 ;
407+ Array . prototype . push . apply ( fixture . componentInstance . singleRecData , fixture . componentInstance . singleRecData2 ) ;
408+ fixture . detectChanges ( ) ;
409+ let $grid = $ ( "#grid1" ) ;
410+ expect ( $grid . data ( "igGrid" ) . allRows ( ) . length === 1 ) . toBeTruthy ( "There should be one record in grid." ) ;
411+ expect ( $ ( $grid . data ( "igGrid" ) . cellById ( 1 , "Name" ) ) . text ( ) === "Test" ) . toBeTruthy ( "Change in text should be reflected in grid." ) ;
412+ done ( ) ;
413+ } ) ;
414+ } ) ;
415+
397416 it ( 'should initialize grid features 2' , ( done ) => {
398417 var template = "<ig-grid [widgetId]='gridID' [width]='gridWidth' [autoCommit]='true' [dataSource]='data' [height]='h' [autoGenerateColumns]='false' [primaryKey]='\"Id\"'>" +
399418 "<column [key]=\"'Id'\" [(headerText)]=\"idHeaderText\" [width]=\"'165px'\" [dataType]=\"'number'\"></column>" +
@@ -699,9 +718,12 @@ class TestComponent {
699718 public opts1 : any ;
700719 public opts2 : any ;
701720 public opts3 : any ;
721+ public optsNew :any ;
702722 private gridID : string ;
703723 public data : Array < any > ;
704724 public data1 : Array < any > ;
725+ public singleRecData : Array < any > ;
726+ public singleRecData2 : Array < any > ;
705727 private cdi : number ;
706728 public pi : number ;
707729 private firedEvent : any ;
@@ -714,6 +736,8 @@ class TestComponent {
714736 @ViewChild ( Infragistics . IgGridComponent ) public viewChild : Infragistics . IgGridComponent ;
715737
716738 constructor ( ) {
739+ this . singleRecData = [ { "Id" : 1 , "Name" : "John Smith" , "Age" : 45 , "HireDate" : "2002-05-09" } ] ;
740+ this . singleRecData2 = [ { "Id" : 1 , "Name" : "Test" , "Age" : 45 , "HireDate" : "2002-05-09" } ] ;
717741 this . gridID = "grid1" ;
718742 this . cdi = 0 ;
719743 this . caption = "My Caption" ;
@@ -783,7 +807,6 @@ class TestComponent {
783807 }
784808 ]
785809 } ;
786-
787810 this . optsAllFeatures = {
788811 width : "700px" ,
789812 height : "400px" ,
@@ -886,7 +909,18 @@ class TestComponent {
886909 } ;
887910
888911 } ;
889-
912+ this . optsNew = {
913+ dataSource : this . singleRecData ,
914+ height : "300px" ,
915+ autoGenerateColumns : false ,
916+ primaryKey : "Id" ,
917+ columns : [
918+ { key : "Id" , headerText : "Id" , dataType : "number" , hidden : true } ,
919+ { key : "Name" , headerText : "Name" , dataType : "string" , width : "100px" } ,
920+ { key : "Age" , headerText : "Age" , dataType : "number" , width : "100px" , template : "Age: ${Age}" } ,
921+ { key : "HireDate" , headerText : "HireDate" , dataType : "date" , width : "100px" } ,
922+ ] } ;
923+ }
890924
891925 public cellClickHandler ( evt ) {
892926 this . firedEvent = evt ;
0 commit comments