How to use ngIf in datatable p-column - primeng

I need to use ngIf in a p-column, but I don't how to get value of datatable.
On primefaces I have "var" option in p:dataTable
I need this:
<p-dataTable [value]="objectList" >
<p-column *ngIf="object.property"></p-column>
</p-dataTable>

Related

Dynamic link to ng-model

I have a table which is created by a jQuery component. In each row there is a select component which I can set to be linked to a ng-model, something like this:
<select ng-model="categories" ng-options="k as v for (k,v) in categories"></select>
My problem is that I don;t know when it is rendered, so I had to use n ugly $timeout, but even calling $scope.$apply() it doesn't bind to the items.
How can I force binding the select with element.
P.S. I'm using AngularJS 1.6
If you have some js code (i.e. jQuery) that creates some angular html, you need to $compile all created html so bindings will work.
I.e. this:
angular.element(document.body).append(angular.element('<input ng-model="x"/>'));
will just add some html, while this:
angular.element(document.body).append($compile(angular.element('<input ng-model="x"/>'))($scope));
will add input and bind x to its value.
http://plnkr.co/edit/PyIO02p3EHzpmC0cUA4V?p=preview

PrimeNG - DataTable sorting

I try to implement a datatable with dynamic column sortable and paginator.
My problem is that sorting doesn't work:
My code:
<p-dataTable [value]="enregistrements" [row]="10" [paginator]="true"
[pageLinks]="3" [rowPerPageOptions]="5,10(20]" scrollable="true" scrollWidth="1200px">
<ng-container *ngFor="let champ of champs; let i = index">
<p-column header="{{champ}}" [sortable]="true" field="{{champ}}">
<ng-template let-enregistrement="rowData" pTemplate type="body">{{enregistrement.champs[i].value}}</ng-template>
<p-column>
</ng-container>
</p-dataTable>
Ideas on what the problem might be?
My code compile and the display is right but when i click on header column to sort it, nothing happens.

angular 4 primeng table column header text in multiple lines

Using primeng table to display the data as grid.
Using below code to display testdate with date format.I would like to display the format part(YYYY-MM-dd) in second line of column.Please suggest
<p-column field="testdate" header="Test Date (YYYY-MM-dd)" [sortable]="true"
[style]="{'width':'150px'}"></p-column>
Use ng-template for that :
<p-column field="testdate" header="Test Date (YYYY-MM-dd)" [sortable]="true"
[style]="{'width':'150px'}" let-testdate="rowData.testdate">
<ng-template pTemplate="body">
{{testate | date: 'YYYY-MM-dd'}}
</ng-template>
</p-column>

primeNg data table: p-column execute function inside "field" attribute?

I am using primeNg library, I don't want to use a for loop inside my angular component to format my date from String to date, is there a way we can directly call component function inside p-column
<p-column field="new Date(createdDate)" [header]="'InputLabel.hold_date_text' | translate"></p-column>
new Date inside p-column doesn't work. is there a way arround
Thanks in advance.
You can't call function in field attribute. If you want, then you could use template like this below way
<p-column field="createdDate" header="Create Date" >
<template let-col let-appdt="rowData" pTemplate="body">
<span>{{new Date(appdt[col.field])}}</span>
</template>
</p-column>

Can I add a property on a directive I created afterwards the page is loaded based on IF condition?

The directive is a attribute (A) one.
HTML:
<input class="form-control" my-amount-field amount-min="5" amount-max="120" shouldBeingChecked="{{crCtrl.form.canCashM}}" name="myLimit" id="myLimit" ng-model="crCtrl.form.limits.cash.val" ng-blur="crCtrl.form.limits.cash.errFn(cardRules)" tabindex="8" />
For this directive I have another attribute which is "allow-zero", but I'd like to put that attribute only IF a specific checkbox is thicked.
I was wondering if I can bind that attribute to the directive "my-amount-field" when the page obviously is already loaded.
Looks like allow-zero it's a boolean property, if that's the case you should add the property with a boolean condition I think .. like allow-zero="{{shouldZeroBeAllowedCondition}}"

Resources