Skip to content

Commit 494be57

Browse files
Merge branch 'master' into ibarakov/fix-7090-master
2 parents 8d3adb8 + dab344a commit 494be57

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
- ` IGX_INPUT_GROUP_TYPE` injection token
2425
- Allows for setting an input group `type` on a global level, so all input-group instances, including components using such an instance as a template will have their input group type set to the one specified by the token. It can be overridden on a component level by explicitly setting a `type`.
2526
- ` IgxExcelExporterService`
@@ -32,7 +33,7 @@ All notable changes for each version of this project will be documented in this
3233
- `IgxOverlay`
3334
- The `PositionSettings` `target` property has been deprecated and moved to `OverlaySettings`.
3435
- An optional Point/HTML Element parameter `target` has been added to the `position()` method
35-
36+
3637
## 10.1.0
3738

3839
### General
@@ -54,7 +55,7 @@ All notable changes for each version of this project will be documented in this
5455
- `igxGrid`
5556
- **Behavioral Change** - For numeric columns, the onCellEdit arguments' newValue will now contain the numeric value that will be committed instead of the string input.
5657
- Added `onScroll` event, which is emitted when the grid is scrolled vertically or horizontally.
57-
- 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.
58+
- 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.
5859
- `igxTreeGrid`
5960
- 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.
6061
- `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
@@ -4209,6 +4209,25 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
42094209
}
42104210
}
42114211

4212+
/**
4213+
* Returns the data that is contained in the row component.
4214+
* @remarks
4215+
* If the primary key is not specified the row selector match the row data.
4216+
* @example
4217+
* ```typescript
4218+
* const data = grid.getRowData(94741);
4219+
* ```
4220+
* @param rowSelector correspond to rowID
4221+
*/
4222+
public getRowData(rowSelector: any) {
4223+
if (!this.primaryKey) {
4224+
return rowSelector;
4225+
}
4226+
const data = this.gridAPI.get_all_data(this.transactions.enabled);
4227+
const index = this.gridAPI.get_row_index_in_data(rowSelector);
4228+
return index < 0 ? {} : data[index];
4229+
}
4230+
42124231
/**
42134232
* Sort a single `IgxColumnComponent`.
42144233
* @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)