File

C:/GoDev/src/TCSTK-Angular/projects/tibco-tcstk/tc-core-lib/src/lib/components/tibco-cloud-select-table/tibco-cloud-select-table.component.ts

Description

A table that allows rows to be selected

Extends

TibcoCloudTableComponent

Example

<tc-tibco-cloud-select-table></tc-tibco-cloud-select-table>

Metadata

selector tc-tibco-cloud-select-table
styleUrls ./tibco-cloud-select-table.component.css
templateUrl ./tibco-cloud-select-table.component.html

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(logger: LogService)
Parameters :
Name Type Optional
logger LogService No

Inputs

jsonSource
Type : string
Inherited from TibcoCloudTableComponent

Outputs

selectedlines
Type : EventEmitter<any>

~event selectedlines : the lines selected ~payload any : The lines that are selected in the table by the user

Methods

Public clicked
clicked(row)
Parameters :
Name Optional
row No
Returns : void
highlight
highlight(element)
Parameters :
Name Optional
element No
Returns : void
camelCaseTW
camelCaseTW(header: string | any)
Inherited from TibcoCloudTableComponent
Parameters :
Name Type Optional
header string | any No
Returns : any
ngOnChanges
ngOnChanges(changes)
Inherited from TibcoCloudTableComponent
Parameters :
Name Optional
changes No
Returns : void
ngOnInit
ngOnInit()
Inherited from TibcoCloudTableComponent
Returns : void
updateTable
updateTable()
Inherited from TibcoCloudTableComponent
Returns : void

Properties

selected
Type : object
Default value : {}
columns
Type : []
Default value : []
Inherited from TibcoCloudTableComponent
dataSource
Type : TibcoCloudTableDataSource
Inherited from TibcoCloudTableComponent
displayedColumns
Type : []
Default value : []
Inherited from TibcoCloudTableComponent

Columns displayed in the table. Columns IDs can be added, removed, or reordered.

id
Type : string
Default value : '_' + Math.random().toString(36).substr(2, 9)
Inherited from TibcoCloudTableComponent
paginator
Type : MatPaginator
Decorators :
@ViewChild(MatPaginator, {static: true})
Inherited from TibcoCloudTableComponent
sort
Type : MatSort
Decorators :
@ViewChild(MatSort, {static: true})
Inherited from TibcoCloudTableComponent
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {TibcoCloudTableComponent} from '../tibco-cloud-table/tibco-cloud-table.component';
import {LogService} from '../../services/tc-logging.service';

/**
 * A table that allows rows to be selected
 *
 *@example <tc-tibco-cloud-select-table></tc-tibco-cloud-select-table>
 */

@Component({
  selector: 'tc-tibco-cloud-select-table',
  templateUrl: './tibco-cloud-select-table.component.html',
  styleUrls: ['./tibco-cloud-select-table.component.css']
})
export class TibcoCloudSelectTableComponent extends TibcoCloudTableComponent {


  /**
   * ~event selectedlines : the lines selected
   * ~payload any : The lines that are selected in the table by the user
   */
  @Output() selectedlines: EventEmitter<any> = new EventEmitter<any>();

  selected = {};

  highlight(element) {
    element.highlighted = !element.highlighted;
  }

  constructor(protected logger: LogService) { /*, protected tcfunctions: TcFunctionsService) {*/
    super();
    logger.info('Select Table Started... ');
  }


  public clicked(row) {
    // console.log(row);
    const myData = JSON.parse(JSON.stringify(this.dataSource.data));
    // console.log(this.dataSource);
    const selectedArray = new Array();
    for (const line of myData) {
      // console.log('s:' , line);
      if (line.highlighted) {
        delete line['hovered'];
        delete line['highlighted'];
        selectedArray.push(line);
      }

    }
    // console.log('Selected Array: ' , selectedArray);
    this.selected = JSON.stringify(selectedArray);
    this.selectedlines.emit(this.selected);
  }


}
<div class="mat-elevation-z8">
  <table id="{{id}}" mat-table class="tcst-full-width-table" [dataSource]="dataSource" matSort aria-label="Elements">
    <ng-container *ngFor="let column of columns" [matColumnDef]='column.columnDef'>
      <mat-header-cell *matHeaderCellDef class="tcst-header" mat-sort-header>{{camelCaseTW(column.header)}}</mat-header-cell>
      <mat-cell *matCellDef="let row" >{{ column.cell(row) }}</mat-cell>
    </ng-container>
    <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
    <mat-row *matRowDef="let row; columns: displayedColumns;  let even = even;"
             [ngClass]="{hovered: row.hovered, highlighted: row.highlighted, tcstgray: even}"
             (click)="row.highlighted = !row.highlighted; clicked(row);" (mouseover)="row.hovered = true" (mouseout)="row.hovered = false"></mat-row>


  </table> <!-- *ngIf="dataSource.data.length > 10" -->
<!-- <div class='' ngClass="{'tcst-hide': dataSource.data.length < 10}"> -->
  <mat-paginator [ngClass]="{'tcst-hide': dataSource.data.length < 10}"  #paginator
                 [length]="dataSource.data.length"
                 [pageIndex]="0"
                 [pageSize]="10"
                 [pageSizeOptions]="[5, 10, 20, 25]">
  </mat-paginator>
</div>
<!--</div>-->

./tibco-cloud-select-table.component.css

.tcst-full-width-table {
  width: 100%;
}

.mat-row.hovered {
  background: #eee;
  cursor: pointer;
}

.mat-row.highlighted {
  background: #999;
}

.tcst-header{
  /*
  background-color: #d0d5e2;
  font-size: 16px;*/
  background: #0081cb;
  color:white;
  padding:5px 30px;
  display:flex;
  align-items: center;
}

.tcst-header:hover{
  background-color: #229be0;
}

.tcstgray {
  background-color: #f5f5f5;
}

.tcst-hide{
  display: none;
}
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""