Skip to content

Commit d0c3c30

Browse files
committed
feat(IgxGrid): adden getRowData public method #7930
1 parent 37f7c06 commit d0c3c30

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

+22
Original file line numberDiff line numberDiff line change
@@ -4129,6 +4129,28 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
41294129
}
41304130
}
41314131

4132+
/**
4133+
* Returns the data that is contained in the row component.
4134+
* @remarks
4135+
* If the primary key is not specified the row selector match the row data.
4136+
* @example
4137+
* ```typescript
4138+
* const data = grid.getRowData({
4139+
* ProductID: 1, ProductName: 'Spearmint', InStock: true, UnitsInStock: 1, OrderDate: new Date('2005-03-21')
4140+
* });
4141+
* const data = grid.getRowData(94741);
4142+
* ```
4143+
* @param rowSelector correspond to rowID
4144+
*/
4145+
public getRowData(rowSelector: any) {
4146+
if (!this.primaryKey) {
4147+
return rowSelector;
4148+
}
4149+
const data = this.gridAPI.get_all_data(this.transactions.enabled);
4150+
const index = this.gridAPI.get_row_index_in_data(rowSelector);
4151+
return index < 0 ? {} : data[index];
4152+
}
4153+
41324154
/**
41334155
* Sort a single `IgxColumnComponent`.
41344156
* @remarks

0 commit comments

Comments
 (0)