Adding scrollbar to p-overlayPanel - css

I have p-overlayPanel which has inside a table that can be very big and apears on all the screen, how can I add scrollbar?
Thanks
<button pButton
type="button"
icon="pi pi-angle-down"
(click)="op.toggle($event)"
iconPos="left"
label="גרסאות קודמות"
[disabled]="!isShowVersionValid()"
class="ui-button-rounded ui-button-secondary"></button>
<p-overlayPanel #op [showCloseIcon]="false" [style]="{'overflow':'visible', 'padding': 0 ,'border':'none'}">
<p-table [columns]="cols" [value]="data">
<ng-template pTemplate="header" let-columns>
<tr>
<th class="ui-column-title thdesign" *ngFor="let col of columns">
{{col.header}}
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-data let-columns="columns" let-rowIndex="rowIndex" >
<tr *ngIf="data.docVersionNumber < length">
<td *ngFor="let col of columns ">
<div *ngIf="!col.isAnchor && !col.isDate" class="colDesign">{{data[col.field]}}</div>
<div *ngIf="col.isDate" class="colDesign">{{ data[col.field] | date: "dd/MM/yyyy HH:mm"}}</div>
<div *ngIf="col.isAnchor && !col.isDate">
<a class="anchor" href="{{templateUrl}}?{{splitCoimPath(data.coimId)}}" target="_blank" rel="noopener noreferrer">
{{data[col.field]}}
</a>
</div>
</td>
</tr>
</ng-template>
</p-table>
</p-overlayPanel>

You can Use overflow:scroll instead of visible :
<p-overlayPanel #op [showCloseIcon]="false" [style]=" {width:'650px','max-height':'550px', overflow:'scroll', 'padding': 0 ,'border':'none'}">

Related

How to make css columns into primeng?

I'm working with primeng. I have this code to display my data.
My Html:
<p-table #table [columns]="cols" [value]="list" [paginator]="true" responsive="false">
<!---------------- Header of datatable event ------------------>
<ng-template pTemplate="colgroup" let-columns>
<colgroup>
<col *ngFor="let col of columns" [ngStyle]="{'width' : col.width}">
</colgroup>
</ng-template>
<ng-template pTemplate="header" let-columns>
<tr>
<th *ngFor="let col of columns">
{{ col.header | translate}}
</th>
</tr>
</ng-template>
<!---------------- Body of datatable event ------------------>
<ng-template pTemplate="body" let-rowData let-columns="columns" let-rowIndex="rowIndex">
<tr [pSelectableRow]="rowData">
<td *ngFor="let col of columns" [ngStyle]="{'width': col.width }">
<div *ngIf="col.field !== 'idOption'">
{{rowData[col.field]}}
</div>
<div *ngIf="col.field === 'idOption'">
{{rowData[col.field]}}
<span *ngIf="rowData.activeOpt">
<em class="fa fa-lg fa-check-circle" style="color: green; padding-left: 50%"></em>
</span>
<span *ngIf="!rowData.activeOpt">
<em class="fa fa-lg fa-check-circle" style="color: red; padding-left: 40%"></em>
</span>
</div>
</td>
</tr>
</ng-template>
</p-table>
I get this result:
I want that the green fa-check-circle will be in the same line, really i spent many time without any solution. Thanks for any help.
The reason why icons are not aligned is because icon is placed just after the text & the length of text will vary based on the Garantie values.
So in order to keep our icons aligned irrespective of the text length, we can fix the alignment to always right [float:right] (not after the text ends).
Please change your active & inactive icon code line with below.
Active icon (green):
<em class="fa fa-lg fa-check-circle" style="color: green; float:right"></em>
Inactive icon (red):
<em class="fa fa-lg fa-check-circle" style="color: red; float:right"></em>

PrimeNG - Keep horizontal layout on PTable in any device

My Ptable looks like this when i see it on desktop/iPad
And when i set my device to something like iPhone X, it looks like this
I would like it to have the horizontal layout on every device. I know its not going to look very nice but still, i need to keep it looking the same everywhere.
Here's the code:
<p-table #dt [value]="pedidos" [rows]="10" [responsive]="true" [resizableColumns]="true"
[paginator]="true" [rowsPerPageOptions]="[10,20,30,50,100]" (sortFunction)="customSort($event)"
[customSort]="true" columnResizeMode="expand" [columns]="selectedColumns" [reorderableColumns]="true"
[globalFilterFields]="['nroPedido','nroOrdenSap', 'nrocliente', 'cliente', 'estado', 'fechaEstado', 'totalLocal', 'total']">
<ng-template pTemplate="caption">
<div class="grid-container">
<div class="grid-x">
<div class="medium-9 cell">
<div class="input-group">
<span class="input-group-label">
<i class="fa fa-search"></i>
</span>
<input type="text" class="input-group-field" size="50"
(input)="dt.filterGlobal($event.target.value, 'contains')" style="width:auto"
placeholder="{{Etiquetas.Buscar}}">
</div>
</div>
<div class="medium-3 cell">
<div style="text-align:left">
<p-multiSelect [options]="cols" [(ngModel)]="selectedColumns" optionLabel="header"
selectedItemsLabel="{0} {{Etiquetas.ColumnasSeleccionadas}}" [style]="{minWidth: '200px'}"
defaultLabel="{{Etiquetas.ElijaColumnas}}">
</p-multiSelect>
</div>
</div>
</div>
</div>
</ng-template>
<ng-template pTemplate="header" let-columns>
<tr *ngIf="pedidos">
<th pResizableColumn [ngStyle]="{'width': this.esMobile ? '10%' : '20%'}">
{{this.esMobile ? '' : 'Acciones'}}
</th>
<th *ngFor="let col of columns" [pSortableColumn]="col.field" [ngStyle]="{'width': col.width}"
pResizableColumn pReorderableColumn>
{{col.header}}
<p-sortIcon [field]="col.field"></p-sortIcon>
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-pedido let-columns="columns">
<tr>
<td>
<button *ngIf="pedido.editar" mat-icon-button matTooltip={{Etiquetas.Editar}}
routerLink="{{pedido.codigo}}">
<mat-icon color="primary">edit</mat-icon>
</button>
<button *ngIf="!pedido.editar" mat-icon-button matTooltip={{Etiquetas.Ver}}
routerLink="{{pedido.codigo}}">
<mat-icon color="primary">remove_red_eye</mat-icon>
</button>
</td>
<td *ngFor="let col of columns">
<span *ngIf="col.field !== 'estado' && col.field !== 'fechaEstado'">
{{ col.type ? col.type.transform(pedido[col.field]) : pedido[col.field] }}
</span>
<span *ngIf="col.field == 'fechaEstado'">
{{ pedido[col.field] }}
</span>
<span *ngIf="col.field == 'estado'" [ngClass]="cStatusClass(pedido.idEstado)"
style="float:center;text-align:center;display:block">
{{ col.type ? col.type.transform(pedido[col.field]) : pedido[col.field] }}
</span>
</td>
</tr>
</ng-template>
</p-table>
Is there a property or maybe something i should change on CSS to make this happen?
Just needed to change this property on the HTML code: [responsive]="false"

How to align p-table and p-chart elements side by side

I have a very little experience developing UI but I wanted to accomplish a task quickly where I have to put a p-table and p-chart elements side by side. I tried to use flex layout as well as float left and right as below but not getting the expected result. How can this be fixed?
<div fxLayout="row" fxLayoutAlign="start center">
<div fxFlex="50%" class="floatLeft">
<p-table [value]="summaryList" [scrollable]="true" scrollHeight="200px"
[resizableColumns]="true" [style]="{width:'500px'}">
<ng-template pTemplate="caption">
XXX Summary
</ng-template>
<ng-template pTemplate="header">
<tr>
<th *ngFor="let col of summaryColumns" [pSortableColumn]="col.field">
{{col.header}}
<p-sortIcon [field]="col.field"></p-sortIcon>
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-summaryList>
<tr>
<td *ngFor="let col of summaryColumns">
{{summaryList[col.field]}}
</td>
</tr>
</ng-template>
</p-table>
</div>
<div class="col-md-4 content-section implementation" fxFlex="50%" class="floatRight">
<p-chart type="line" [data]="dailyData" title="XXX Chart" extender="overrideXAxis"></p-chart>
</div>
</div>
You can try doing this.
<div class="container">
<p-table [value]="summaryList" height="200" [scrollable]="true" scrollHeight="100px" [resizableColumns]="true" [style]="{width:'50%', float:'left'} ">
<ng-template pTemplate="caption">
My Awesome Summary
</ng-template>
<ng-template pTemplate="header">
<tr>
<th *ngFor="let col of summaryColumns" [pSortableColumn]="col.field">
{{col.header}}
<p-sortIcon [field]="col.field"></p-sortIcon>
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-summaryList>
<tr>
<td *ngFor="let col of summaryColumns">
{{summaryList[col.field]}}
</td>
</tr>
</ng-template>
</p-table>
<p-chart height="250" [responsive]="false" type="bar" [data]="data" [options]="options" [style]="{width:'48%', float:'right'}"></p-chart>
</div>
then add style to your component.css
.container{
display: flex;
justify-content: center;
align-items: center;
}

Why am I getting 'TypeError: Cannot read property 'slice' of undefined'?

I am working on a small project. It is an ASP.NET MVC/Angular5 project. I am simply trying to populate a tableView (PrimeNG) with data that is selected from a Modal or PrimeNG Dialog.
Here is a snipit of the relevent ts file:
displayIndexDialog: boolean;
index: Index = {};
selectedIndex: Index;
newIndex: boolean;
indexes: Index[];
//METHODS
getIndexes() {
this._indexesService.getIndexes().subscribe(indexes => this.indexList = indexes);
}
showIndexAdd() {
this.newIndex = true;
this.selectedIndex = {};
this.displayIndexDialog = true;
this.getIndexes();
}
closeIndexDialog() {
this.displayIndexDialog = false;
}
saveIndex() {
let index = [...this.indexes];
if (this.newIndex) {
index.push(this.index);
}else
index[this.indexes.indexOf(this.selectedIndex)] = this.index;
this.indexes = index;
this.indexes = null;
this.displayIndexDialog = false;
};
//INTERFACE
interface Index {
defaultIndex?;
pK_Index ?;
description ?;
}
Here is the relevent HTML:
<!--INDEX TABLE-->
<p-table [columns]="cols3" [value]="indexes">
<ng-template pTemplate="header" let-columns>
<tr>
<th *ngFor="let col of columns">
{{col.header}}
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData let-columns="columns">
<tr [pSelectableRow]="rowData">
<td *ngFor="let col of columns">
{{rowData[col.field]}}
</td>
</tr>
</ng-template>
<ng-template pTemplate="summary" let-rowData>
<div style="text-align:left">
<button class="btn-cblt" type="button" pButton icon="fa-plus" (click)="showIndexAdd()" label="Add"></button>
</div>
</ng-template>
</p-table><br />
<h4>Differentials</h4>
<p-table [columns]="cols2" [value]="diffs1">
<ng-template pTemplate="header" let-columns>
<tr>
<th *ngFor="let col of columns">
{{col.header}}
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData let-columns="columns">
<tr [pSelectableRow]="rowData">
<td *ngFor="let col of columns">
{{rowData[col.field]}}
</td>
</tr>
</ng-template>
<ng-template pTemplate="summary" let-rowData>
<div style="text-align:left">
<button class="btn-cblt" type="button" pButton icon="fa-plus" (click)="showDifferentialAdd()" label="Add"></button>
</div>
</ng-template>
</p-table>
<!--ADD INDEX DIALOG-->
<p-dialog class="sha" header="Add Index" [(visible)]="displayIndexDialog" [responsive]="true" showEffect="fade" [modal]="true" [width]="600" [height]="300">
<div class="ui-g ui-fluid" *ngIf="selectedIndex">
<div class="ui-g-12">
<div class="ui-g-4">
<label for="Index">Index</label>
</div>
<div class="ui-g-8">
<p-dropdown id="index" placeholder="Select an Index" [options]="indexList" [(ngModel)]="selectedIndex.description" [ngModelOptions]="{standalone: true}" optionLabel="description" [showClear]="true"> </p-dropdown>
</div>
</div>
<div class="ui-g-12">
<div class="ui-g-4">
<label for="isDefault">Default Index?</label>
</div>
<div class="ui-g-8">
<p-checkbox name="defaultIndex" id="isDefault" [(ngModel)]="selectedIndex.defaultIndex"></p-checkbox>
</div>
</div>
<div id="indexName">{{index.pK_Index ? index.pK_Index: ' ' }}</div>
</div>
<div class="ui-dialog-buttonpane ui-helper-clearfix">
<button class="btn-cblt" type="button" pButton icon="fa-check" (click)="saveIndex()" label="Save"></button>
<button class="btn-cblt-danger" type="button" pButton icon="fa-close" (click)="closeIndexDialog()" label="Cancel"></button>
</div>
</p-dialog>
Every time I click the 'save' button on the dialog, in the console I get:

I have been staring at this for 3 days now and Have no idea why this isn't working. Please help!
The Resolution to this was #ConnorsFan 's suggestion. The indexes were not initialized. Setting indexes: Index[] = [] fixed the issue. Thank you #ConnorsFan.

Angular Ui bootstrap dropdown split-button issue with table

I have an angular app , and have integrated angular-ui-bootstrap , my issue is that the dropdown links are are being blocked by table row , using z-index :
<div class="panel panel-default">
<div class="panel-body">
<div class=" pull-right">
<!-- Split button -->
<div class="btn-group invoice_new_item_btn_ul" uib-dropdown>
<button id="split-button" type="button" class="btn btn-danger"> Add Item </button>
<button type="button" class="btn btn-danger" uib-dropdown-toggle>
<span class="caret"></span>
</button>
<ul class="invoice_new_item_btn_ul uib-dropdown-menu" role="menu" aria-labelledby="split-button">
<li role="menuitem">Action</li>
</ul>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped" >
<thead>
<tr>
<th></th>
<th>Item Name</th>
<th>Type</th>
</tr>
</thead>
<tbody id="search_result">
<tr class="odd gradeX" ng-repeat="u in vm.patient.patient_finance_item">
<td></td>
<td ng-bind="u.item_name"></td>
<td ng-bind="u.item_type"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
The css/sass :
.invoice_new_item_btn_ul{
z-index:1000 !important;
}
uib-dropdown-menu only works as an attribute, not a class, which is why your drop down menu is not displaying.
https://github.com/angular-ui/bootstrap/blob/master/src/dropdown/dropdown.js#L285-L287

Resources