Skip to content

Commit 78d1470

Browse files
authored
Merge branch 'master' into mdragnev/add-row-transactions
2 parents 893f082 + dab344a commit 78d1470

File tree

5 files changed

+109
-3
lines changed

5 files changed

+109
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ All notable changes for each version of this project will be documented in this
77
- `IgxDatePicker`
88
- Added `aria-labelledby` property for the input field. This will ensure the users of assistive technologies will also know what component is used for, upon input focus.
99
- `IgxInputGroup`
10-
- **Breaking Change** - Removed `fluent`, `fluent_search`, `bootstrap`, and `indigo` as possible values for the `type` input property.
10+
- **Breaking Change** - Removed `fluent`, `fluent_search`, `bootstrap`, and `indigo` as possible values for the `type` input property.
1111
- **Behavioral Change** - The styling of the input group is now dictated by the theme being used. The remaining `types` - `line`, `border`, and `box` will only have effect on the styling when used with the `material` theme. The `search` type will affect styling when used with all themes. Changing the theme at runtime will not change the styling of the input group, a page refresh is required.
1212
- `IgxOverlay`
1313
- **Breaking Change** - `target` property in `PositionSettings` has been deprecated. You can set the attaching target for the component to show in `OverlaySettings` instead.
@@ -20,6 +20,7 @@ All notable changes for each version of this project will be documented in this
2020
### New Features
2121
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
2222
- When triggering an export of the grid via the toolbar and the export takes more than 500 milliseconds, the export button becomes disabled and an indeterminate progress bar is shown at the bottom of the toolbar until the export is finished.
23+
- Added *getRowData(rowSelector)* method that returns an object that represents the data that is contained in the specified row component.
2324
- Added ability to spawn row adding UI through exoposed methods. Note that rowEditing should be enabled.
2425
- `beginAddRow` method which starts the adding row UI.
2526
- `beginAddChild` method which starts the adding child UI.
@@ -47,7 +48,7 @@ All notable changes for each version of this project will be documented in this
4748
- `IgxOverlay`
4849
- The `PositionSettings` `target` property has been deprecated and moved to `OverlaySettings`.
4950
- An optional Point/HTML Element parameter `target` has been added to the `position()` method
50-
51+
5152
## 10.1.0
5253

5354
### General
@@ -69,7 +70,7 @@ All notable changes for each version of this project will be documented in this
6970
- `igxGrid`
7071
- **Behavioral Change** - For numeric columns, the onCellEdit arguments' newValue will now contain the numeric value that will be committed instead of the string input.
7172
- Added `onScroll` event, which is emitted when the grid is scrolled vertically or horizontally.
72-
- Each grid now expose a default handling for boolean column types. The column will display `check` or `close` icon, instead of true/false by default.
73+
- Each grid now expose a default handling for boolean column types. The column will display `check` or `close` icon, instead of true/false by default.
7374
- `igxTreeGrid`
7475
- Removed `onDataPreLoad` event as it is specific for remote virtualization implementation, which is not supported for the `igxTreeGrid`. A more generic `onScroll` event is exposed and can be used instead.
7576
- `IgxTimePicker`

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4221,6 +4221,25 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
42214221
}
42224222
}
42234223

4224+
/**
4225+
* Returns the data that is contained in the row component.
4226+
* @remarks
4227+
* If the primary key is not specified the row selector match the row data.
4228+
* @example
4229+
* ```typescript
4230+
* const data = grid.getRowData(94741);
4231+
* ```
4232+
* @param rowSelector correspond to rowID
4233+
*/
4234+
public getRowData(rowSelector: any) {
4235+
if (!this.primaryKey) {
4236+
return rowSelector;
4237+
}
4238+
const data = this.gridAPI.get_all_data(this.transactions.enabled);
4239+
const index = this.gridAPI.get_row_index_in_data(rowSelector);
4240+
return index < 0 ? {} : data[index];
4241+
}
4242+
42244243
/**
42254244
* Sort a single `IgxColumnComponent`.
42264245
* @remarks

projects/igniteui-angular/src/lib/grids/grid/grid.component.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,39 @@ describe('IgxGrid Component Tests #grid', () => {
16371637
scrollPosition: grid.headerContainer.getScrollForIndex(6, true),
16381638
event: horizontalScrollEvent
16391639
});
1640+
});
1641+
1642+
it(`Verify that getRowData returns correct data`, () => {
1643+
const fix = TestBed.createComponent(IgxGridDefaultRenderingComponent);
1644+
fix.componentInstance.initColumnsRows(5, 5);
1645+
fix.detectChanges();
1646+
1647+
const grid = fix.componentInstance.grid;
1648+
const cols = fix.componentInstance.columns;
1649+
1650+
const row = {'col0': 0, 'col1': 4, 'col2': 8, 'col3': 12, 'col4': 16};
1651+
const secondRow = {'col0': 0, 'col1': 1, 'col2': 2, 'col3': 3, 'col4': 4};
1652+
1653+
expect(grid.getRowData(row)).toEqual(row);
1654+
1655+
grid.primaryKey = 'col1';
1656+
fix.detectChanges();
1657+
1658+
expect(grid.getRowData(4)).toEqual(row);
1659+
1660+
grid.filter(cols[1].key, 2, IgxNumberFilteringOperand.instance().condition('greaterThan'));
1661+
fix.detectChanges();
1662+
1663+
expect(grid.getRowData(4)).toEqual(row);
1664+
expect(grid.getRowData(1)).toEqual(secondRow);
1665+
expect(grid.getRowData(7)).toEqual({});
1666+
1667+
grid.sort({ fieldName: 'col2', dir: SortingDirection.Desc, ignoreCase: true });
1668+
fix.detectChanges();
16401669

1670+
expect(grid.getRowData(4)).toEqual(row);
1671+
expect(grid.getRowData(1)).toEqual(secondRow);
1672+
expect(grid.getRowData(7)).toEqual({});
16411673
});
16421674
});
16431675

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.integration.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,26 @@ describe('IgxHierarchicalGrid Integration #hGrid', () => {
225225
fixture.detectChanges();
226226
expect(childGrid.getCellByColumn(0, 'ProductName').nativeElement.innerText).toEqual('Product: A0');
227227
}));
228+
229+
it('should return correctly the rowData', () => {
230+
hierarchicalGrid.primaryKey = 'ID';
231+
fixture.detectChanges();
232+
233+
const rowData = hierarchicalGrid.getRowByKey('2').rowData;
234+
expect(hierarchicalGrid.getRowData('2')).toEqual(rowData);
235+
236+
hierarchicalGrid.sort({ fieldName: 'ChildLevels', dir: SortingDirection.Desc, ignoreCase: true });
237+
fixture.detectChanges();
238+
239+
expect(hierarchicalGrid.getRowData('2')).toEqual(rowData);
240+
expect(hierarchicalGrid.getRowData('101')).toEqual({});
241+
242+
hierarchicalGrid.filter('ID', '1', IgxStringFilteringOperand.instance().condition('startsWith'));
243+
fixture.detectChanges();
244+
245+
expect(hierarchicalGrid.getRowData('2')).toEqual(rowData);
246+
expect(hierarchicalGrid.getRowData('101')).toEqual({});
247+
});
228248
});
229249

230250
describe('Sorting', () => {

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-integration.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,40 @@ describe('IgxTreeGrid - Integration #tGrid', () => {
11701170
expect(() => grid.addRow(grid.data, 1)).toThrow(Error(`Cannot add child row to deleted parent row`));
11711171
expect(grid.transactions.getTransactionLog().length).toBe(1);
11721172
}));
1173+
1174+
it('should return correctly the rowData', fakeAsync(() => {
1175+
const fixture = TestBed.createComponent(IgxTreeGridRowEditingTransactionComponent);
1176+
const grid = (fixture as ComponentFixture<IgxTreeGridRowEditingTransactionComponent>).componentInstance.treeGrid;
1177+
grid.cascadeOnDelete = false;
1178+
tick();
1179+
fixture.detectChanges();
1180+
1181+
const row = {'ID': 2, 'ParentID': 1, 'Name': 'Gilberto Todd', 'JobTitle': 'Director', 'Age': 41};
1182+
expect(grid.getRowData(2)).toEqual(row);
1183+
1184+
grid.sort({ fieldName: 'Age', dir: SortingDirection.Desc, ignoreCase: true });
1185+
fixture.detectChanges();
1186+
1187+
expect(grid.getRowData(2)).toEqual(row);
1188+
expect(grid.getRowData(11)).toEqual({});
1189+
1190+
grid.filter('Age', 43, IgxNumberFilteringOperand.instance().condition('greaterThan'));
1191+
fixture.detectChanges();
1192+
1193+
expect(grid.getRowData(2)).toEqual(row);
1194+
expect(grid.getRowData(11)).toEqual({});
1195+
1196+
const newRow = {'ID': 11, 'ParentID': 1, 'Name': 'Joe Peterson', 'JobTitle': 'Manager', 'Age': 37};
1197+
grid.addRow(newRow);
1198+
fixture.detectChanges();
1199+
1200+
grid.clearFilter();
1201+
tick();
1202+
fixture.detectChanges();
1203+
1204+
expect(grid.transactions.getTransactionLog().length).toEqual(1);
1205+
expect(grid.getRowData(11)).toEqual(newRow);
1206+
}));
11731207
});
11741208

11751209
describe('Multi-column header', () => {

0 commit comments

Comments
 (0)