@@ -209,6 +209,25 @@ export function main() {
209209 } ) ;
210210 } ) ;
211211 } ) ;
212+
213+ it ( "should detect changes when original data source is changed but the data source length is the same." , ( done ) => {
214+ var template = '<ig-hierarchical-grid [(widgetId)]="gridID" [(options)]="optsNew"></ig-hierarchical-grid>' ;
215+ TestBed . overrideComponent ( TestComponent , {
216+ set : {
217+ template : template
218+ }
219+ } ) ;
220+ TestBed . compileComponents ( ) . then ( ( ) => {
221+ var fixture = TestBed . createComponent ( TestComponent ) ;
222+ fixture . componentInstance . singleRecData . length = 0 ;
223+ Array . prototype . push . apply ( fixture . componentInstance . singleRecData , fixture . componentInstance . singleRecData2 ) ;
224+ fixture . detectChanges ( ) ;
225+ let $grid = $ ( "#grid1" ) ;
226+ expect ( $grid . data ( "igGrid" ) . allRows ( ) . length === 1 ) . toBeTruthy ( "There should be one record in grid." ) ;
227+ expect ( $ ( $grid . data ( "igGrid" ) . cellById ( 1 , "Name" ) ) . text ( ) === "Test" ) . toBeTruthy ( "Change in text should be reflected in grid." ) ;
228+ done ( ) ;
229+ } ) ;
230+ } ) ;
212231 } ) ;
213232}
214233
@@ -218,9 +237,13 @@ export function main() {
218237} )
219238class TestComponent {
220239 private opts : any ;
240+ private optsNew : any ;
221241 private gridID : string ;
222242 public data : any ;
223243 protected cdi = 0 ;
244+ public singleRecData : Array < any > ;
245+ public singleRecData2 : Array < any > ;
246+
224247 @ViewChild ( Infragistics . IgHierarchicalGridComponent ) public viewChild : Infragistics . IgHierarchicalGridComponent ;
225248
226249 constructor ( ) {
@@ -249,7 +272,21 @@ class TestComponent {
249272 ]
250273 }
251274 ] ;
252-
275+ this . singleRecData = [ {
276+ "ID" : 0 ,
277+ "Name" : "Food" ,
278+ "Products" : [
279+ { "ID" : 0 , "Name" : "Bread" , "Price" : "2.5" }
280+ ]
281+ } ] ;
282+ this . singleRecData2 = [ {
283+ "ID" : 1 ,
284+ "Name" : "Test" ,
285+ "Products" : [
286+ { "ID" : 1 , "Name" : "Milk" , "Price" : "3.5" } ,
287+ { "ID" : 2 , "Name" : "Vint soda" , "Price" : "20.9" }
288+ ]
289+ } ] ;
253290 this . gridID = "grid1" ;
254291 this . opts = {
255292 autoCommit : true ,
@@ -283,5 +320,32 @@ class TestComponent {
283320 }
284321 ]
285322 } ;
323+ this . optsNew = {
324+ autoCommit : true ,
325+ dataSource : this . singleRecData ,
326+ primaryKey : "ID" ,
327+ width : "100%" ,
328+ height : "400px" ,
329+ autoGenerateColumns : false ,
330+ autoGenerateColumnLayouts : false ,
331+ columns : [
332+ { headerText : "ID" , key : "ID" , width : "50px" , dataType : "number" } ,
333+ { headerText : "Name" , key : "Name" , width : "130px" , dataType : "string" }
334+ ] ,
335+ columnLayouts : [
336+ {
337+ key : "Products" ,
338+ responseDataKey : "" ,
339+ childrenDataProperty : "Products" ,
340+ autoGenerateColumns : false ,
341+ primaryKey : "ID" ,
342+ columns : [
343+ { key : "ID" , headerText : "ID" , width : "25px" } ,
344+ { key : "Name" , headerText : "Product Name" , width : "90px" } ,
345+ { key : "Price" , headerText : "Price" , dataType : "number" , width : "55px" }
346+ ]
347+ }
348+ ]
349+ } ;
286350 }
287351}
0 commit comments