PrimeNG - Keep horizontal layout on PTable in any device - css

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"

Related

How to insert multiple checkbox values into firebase using vue js

I've a form that contains a textarea and a table with a list of many members (from a collection named Members). Each table's contain two checboxes: one to mark the presence of the member and the second one to mark his payment. After clicking on the submit button I'd like to have in my firebase database something like this:
Meeting collection:
associationId,
textareaValue,
createdAd
Presence collection:
memberId,
meetingId,
present: true or false,
createAt
Payment collection:
memberId,
meetingId,
payment: true or false,
createAt
<form #submit.prevent="handleSubmitNewMeeting">
<!-- step one -->
<div class="card" v-if="showFormPart1">
<div class="card-header">
<h4>Entrer le sujet principal de la réunion</h4>
</div>
<div class="card-body">
<div class="form-group">
<textarea class="form-control" v-model="subjects" required rows="3"></textarea>
</div>
<p></p>
<div class="row">
<div class="col-sm-6">
<button #click="showForm=false" class="btn btn-danger" style="width: 100%">
Annuler
</button>
</div>
<div class="col-sm-6">
<button
type="button" class="btn btn-outline-secondary" #click="showFormPart2=true;
showFormPart1=false;">
Suivant
</button>
</div>
</div>
</div>
</div>
<p></p>
<!-- step two -->
<div class="card" v-if="showFormPart2">
<div v-if="members">
<div class="card-header">
<h4>Cocher les présences et payements</h4>
</div>
<div class="card-block p-0">
<table class="table table-bordered">
<thead class="">
<tr align="center">
<th scope="col">Nom</th>
<th scope="col">Prénom</th>
<th scope="col">Téléphone</th>
<th scope="col">Présence</th>
<th scope="col">Payment</th>
</tr>
</thead>
<tbody>
<tr v-for="member in members" :key="member.id" align="center">
<td>{{ member.memberFirstname }}</td>
<td>{{ member.memberLastname }}</td>
<td>{{ member.memberPhoneNumber }}</td>
<td>
<label class="switch">
<input type="checkbox" class="default" v-model="present">
<span class="slider round"></span>
</label>
</td>
<td>
<label class="switch">
<input type="checkbox" class="default" v-model="payment">
<span class="slider round"></span>
</label>
</td>
</tr>
</tbody>
</table>
<p></p>
<div class="row">
<div class="col-sm-6">
<button
type="button" class="btn btn-outline-secondary" #click="showFormPart2=false;
showFormPart1=true;">
Précédent
</button>
</div>
<div class="col-sm-6">
<button class="btn btn-secondary"> Valider </button>
</div>
</div>
</div>
</div>
</div>
<p></p>
</form>
How to do these with firebase using Vue Js please ? thanks !

Adding scrollbar to p-overlayPanel

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'}">

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>

Form Validation with font awesome icons inside ng-repeat

Good Afternoon,
I'm having a problem trying to get my font awesome icons to work as expected, I have a shopping cart where hardware can be ordered, an address field is provided for each item so the user can send hardware to different locations, as each location is provided I want the icon to change from a cross to a tick, I'm using AngluarJS form validation:
Problem I have is the icon only changes when the last address is entered, I'm sure I need to use an $index or something like it but can't figure it out:
Here is my code...
<table id="cart" class="table table-hover table-condensed">
<thead>
<tr>
<th style="width:55%;">${Product} </th>
<th style="width: 1%;">${Quantity}</th>
<th style="width: 24%;">${Delivery Address:}</th>
<th style="width: 1%;"></th>
<th style="width: 19%;"><span style="visibility: hidden;">${Item Controls}</span></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in c.data.cartItems track by item.sys_id | orderBy: 'order'">
<td data-th="Product">
<div class="row">
<div class="col-sm-2 visible-lg"><img ng-show="item.picture" ng-src="{{item.picture}}" alt="{{item.name}}" class="img-responsive item-image"/></div>
<div class="col-sm-10">
<h2 class="nomargin h4">{{item.name}}</h2>
<p class="hidden-xs">{{item.short_description}}</p>
{{item.sys_id}}
</div>
</div>
</td>
<td data-th="Quantity">
<input type="number"
title="${Quantity}"
ng-if="item.show_quantity"
class="form-control text-center"
ng-model="item.quantity"
min="1"
max="20"
ng-model-options="{ updateOn: 'blur' }"
ng-change="c.updateQuantity(item)">
<span ng-if="!item.show_quantity">-</span>
</td>
<td>
<select ng-model="address" name="address" ng-options="address.value for address in data.userAddress | filter:{u_active_address:'true'} track by address.value"
ng-change="c.updateAddress(item.quantity, item.sys_id, address.value, $index, item)"
id="address" class="dropdown pull-right" style="height: 30px;">
</select>
</td>
<td>
<i ng-show="myForm.address.$dirty" class="fa fa-check-circle" style="color:#008000;">{{myForm.address.$dirty}}</i>
<i ng-show="myForm.address.$pristine" class="fa fa-exclamation-circle" style="color:#FF6347;">{{myForm.address.$pristine}}</i>
</td>
<td class="col-md-12 text-right">
<button title="Edit" class="btn btn-info btn-sm" data-toggle="modal" data-target="#myModal" aria-label="${Edit Item} {{item.name}}" ng-show="item.has_options" ng-click="c.editItem(item.sys_id)"><i class="fa fa-edit"></i></button>
<button title="Remove" class="btn btn-danger btn-sm" aria-label="${Remove Item From Cart} {{item.name}}" ng-click="c.removeItem($event, item)"><i class="fa fa-trash"></i></button>
</td>
</tr>
</tbody>
</table>
Lines of interest:
<select ng-model="address" name="address" ng-options="address.value for address in data.userAddress | filter:{u_active_address:'true'} track by address.value"
ng-change="c.updateAddress(item.quantity, item.sys_id, address.value, $index, item)"
id="address" class="dropdown pull-right" style="height: 30px;">
</select>
<td>
<i ng-show="myForm.address.$dirty" class="fa fa-check-circle" style="color:#008000;">{{myForm.address.$dirty}}</i>
<i ng-show="myForm.address.$pristine" class="fa fa-exclamation-circle" style="color:#FF6347;">{{myForm.address.$pristine}}</i>
</td>
Images Attached:
Cart OnLoad
Last Address Changed
Any help and I would be grateful
Found the solution here:
How to validate inputs dynamically created using ng-repeat, ng-show (angular)
Updated Code:
<td>
<select ng-model="address" name="address{{$index}}" ng-options="address.value for address in data.userAddress | filter:{u_active_address:'true'} track by address.value"
ng-change="c.updateAddress(item.quantity, item.sys_id, address.value, $index)"
id="address" class="dropdown pull-right" style="height: 30px;">
</select>
</td>
<td>
<i ng-show="myForm['address' + $index].$dirty" class="fa fa-check-circle" style="color:#008000;"> {{myForm.address.$dirty}}{{fieldUpdated}}</i>
<i ng-show="myForm['address' + $index].$pristine" class="fa fa-exclamation-circle" style="color:#FF6347;"> {{myForm.address.$pristine}}</i>
</td>

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.

Resources