@@ -792,27 +792,70 @@ export class IgxSummaryRow implements RowType {
792792 }
793793}
794794
795- export class IgxPivotGridRow extends BaseRow {
796- /**
797- * @hidden
795+ export class IgxPivotGridRow implements RowType {
796+
797+ /** The index of the row within the grid */
798+ public index : number ;
799+
800+ /**
801+ * The grid that contains the row.
798802 */
799- constructor (
800- public override grid : GridType ,
801- public override index : number , data ?: any
802- ) {
803- super ( ) ;
803+ public grid : GridType ;
804+ private _data ?: any ;
805+
806+ constructor ( grid : GridType , index : number , data ?: any ) {
807+ this . grid = grid ;
808+ this . index = index ;
804809 this . _data = data && data . addRow && data . recordRef ? data . recordRef : data ;
805810 }
806811
807812 /**
808- * Gets the rendered cells in the row component.
813+ * The data passed to the row component.
809814 */
810- public override get cells ( ) : CellType [ ] {
811- const res : CellType [ ] = [ ] ;
812- this . grid . columns . forEach ( col => {
813- const cell : CellType = new IgxGridCell ( this . grid , this . index , col ) ;
814- res . push ( cell ) ;
815- } ) ;
816- return res ;
815+ public get data ( ) : any {
816+ return this . _data ?? this . grid . dataView [ this . index ] ;
817+ }
818+
819+ /**
820+ * Returns the view index calculated per the grid page.
821+ */
822+ public get viewIndex ( ) : number {
823+ return this . index + this . grid . page * this . grid . perPage ;
824+ }
825+
826+ /**
827+ * Gets the row key.
828+ * A row in the grid is identified either by:
829+ * - primaryKey data value,
830+ * - the whole rowData, if the primaryKey is omitted.
831+ *
832+ * ```typescript
833+ * let rowKey = row.key;
834+ * ```
835+ */
836+ public get key ( ) : any {
837+ const data = this . _data ?? this . grid . dataView [ this . index ] ;
838+ const primaryKey = this . grid . primaryKey ;
839+ return primaryKey ? data [ primaryKey ] : data ;
840+ }
841+
842+ /**
843+ * Gets whether the row is selected.
844+ * Default value is `false`.
845+ * ```typescript
846+ * row.selected = true;
847+ * ```
848+ */
849+ public get selected ( ) : boolean {
850+ return this . grid . selectionService . isRowSelected ( this . key ) ;
851+ }
852+
853+ public set selected ( val : boolean ) {
854+ if ( val ) {
855+ this . grid . selectionService . selectRowsWithNoEvent ( [ this . key ] ) ;
856+ } else {
857+ this . grid . selectionService . deselectRowsWithNoEvent ( [ this . key ] ) ;
858+ }
859+ this . grid . cdr . markForCheck ( ) ;
817860 }
818861}
0 commit comments