@@ -269,6 +269,53 @@ describe('Basic IgxHierarchicalGrid', () => {
269269 expect ( childGrid . displayDensity ) . toBe ( DisplayDensity . compact ) ;
270270 } ) ) ;
271271
272+ it ( 'should update child grid data when root grid data is changed.' , ( ) => {
273+ const newData1 = [
274+ {
275+ ID : 0 , ChildLevels : 0 , ProductName : 'Product: A' , childData : [ { ID : 1 , ProductName : 'Product: Child A' } ]
276+ } ,
277+ {
278+ ID : 1 , ChildLevels : 0 , ProductName : 'Product: A1' , childData : [ { ID : 2 , ProductName : 'Product: Child A' } ]
279+ } ,
280+ {
281+ ID : 2 , ChildLevels : 0 , ProductName : 'Product: A2' , childData : [ { ID : 3 , ProductName : 'Product: Child A' } ]
282+ }
283+ ] ;
284+ fixture . componentInstance . data = newData1 ;
285+ fixture . detectChanges ( ) ;
286+ let row = hierarchicalGrid . getRowByIndex ( 0 ) as IgxHierarchicalRowComponent ;
287+ UIInteractions . clickElement ( row . expander ) ;
288+ fixture . detectChanges ( ) ;
289+ let childGrids = fixture . debugElement . queryAll ( By . css ( 'igx-child-grid-row' ) ) ;
290+ let childGrid = childGrids [ 0 ] . query ( By . css ( 'igx-hierarchical-grid' ) ) . componentInstance ;
291+
292+ expect ( childGrid . data ) . toBe ( newData1 [ 0 ] . childData ) ;
293+
294+ const newData2 = [
295+ {
296+ ID : 0 , ChildLevels : 0 , ProductName : 'Product: A' , childData : [ { ID : 10 , ProductName : 'Product: New Child A' } ]
297+ } ,
298+ {
299+ ID : 1 , ChildLevels : 0 , ProductName : 'Product: A1' , childData : [ { ID : 20 , ProductName : 'Product: New Child A' } ]
300+ } ,
301+ {
302+ ID : 2 , ChildLevels : 0 , ProductName : 'Product: A2' , childData : [ { ID : 30 , ProductName : 'Product: New Child A' } ]
303+ }
304+ ] ;
305+ fixture . componentInstance . data = newData2 ;
306+ fixture . detectChanges ( ) ;
307+
308+ row = hierarchicalGrid . getRowByIndex ( 0 ) as IgxHierarchicalRowComponent ;
309+ UIInteractions . clickElement ( row . expander ) ;
310+ fixture . detectChanges ( ) ;
311+
312+ childGrids = fixture . debugElement . queryAll ( By . css ( 'igx-child-grid-row' ) ) ;
313+ childGrid = childGrids [ 0 ] . query ( By . css ( 'igx-hierarchical-grid' ) ) . componentInstance ;
314+
315+ expect ( childGrid . data ) . toBe ( newData2 [ 0 ] . childData ) ;
316+
317+ } ) ;
318+
272319 it ( 'when child width is in percents its width should be update if parent width changes while parent row is collapsed. ' , async ( ) => {
273320 const row = hierarchicalGrid . getRowByIndex ( 0 ) as IgxHierarchicalRowComponent ;
274321 UIInteractions . clickElement ( row . expander ) ;
0 commit comments