The code I was using before DataTable worked fine.
Whenever Records was changed in the Component, the table updated immediately.
<tr *ngFor="let record of Records >
<td>{{record.nurseryCode }}</td>
<td>{{record.nurseryName}}</td>
<td>{{record.status}} </td>
</tr>
Is there any way I can get Data table to do the same please ?
DataTable does not refresh if the underlying data is changed
I think nobody understands what exactly you want. Your code doesnt explain anything, and you dont have any code that doesnt work for you in a dataTable, how are people supposed to help you?meerkatinfrance wrote:The code I was using before DataTable worked fine.
Whenever Records was changed in the Component, the table updated immediately.
<tr *ngFor="let record of Records >
<td>{{record.nurseryCode }}</td>
<td>{{record.nurseryName}}</td>
<td>{{record.status}} </td>
</tr>
Is there any way I can get Data table to do the same please ?
I think, you might want sthg like this?
Code: Select all
<p-dataTable #dt [value]="Records" [(selection)]="selectedRecord" [editable]="true" [paginator]="false" [rows]="10" [responsive]="true" >
<p-column field="profile" header="NurseryCody" [sortable]="false" [editable]="true"> </p-column>
<p-column field="hours" header="NurseryName" [sortable]="false" [editable]="true"> </p-column>
<p-column field="limit" header="Status" [editable]="true" [style]="{'overflow':'visible'}">
<template pTemplate="editor" let-col let-profile="rowData">
<p-dropdown [options]="YourOptions" [autoWidth]="false" [(ngModel)]="record.status" [style]="{'width':'100%'}" </p-dropdown>
</template>
</p-column>
</p-dataTable>
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
DataTable is aware of change detection, if you share some details like your code it may give a clue.
-
- Posts: 5
- Joined: 13 Feb 2017, 23:33
I am so sorry, you are correct. Your Datatable IS aware of change detection.
I made a mistake and I gladly accept all the criticism of my post.
I will be more careful in future and I thank you for your attention.
I made a mistake and I gladly accept all the criticism of my post.
I will be more careful in future and I thank you for your attention.
I have a similar issue, how did you solve it? Which primeng version are you using (I am using 2.0.0)?meerkatinfrance wrote:I am so sorry, you are correct. Your Datatable IS aware of change detection.
I made a mistake and I gladly accept all the criticism of my post.
I will be more careful in future and I thank you for your attention.
We are having the same problem in our application. We use the datatable component in two places. In both places the datatable does not react on changes in the model.
The example below (simplified) should display a table of log entries.
After the component is initialized in ngInit the data is loaded and the datatable should update.
No errors are reported in the console.
The example below (simplified) should display a table of log entries.
After the component is initialized in ngInit the data is loaded and the datatable should update.
No errors are reported in the console.
Code: Select all
<p-dataTable [value]="logs" emptyMessage="{{ 'list.noItemsFound' | translate }}">
<p-column header="Time" [style]="{'width':'120px'}">
<ng-template let-row="rowData" pTemplate="body">
{{row.timestamp | date:'dd.MM.y HH:mm'}}
</ng-template>
</p-column>
<p-column header="Log" [style]="{'width':'440px'}">
<ng-template let-row="rowData" pTemplate="body">
{{row.message}}
</ng-template>
</p-column>
</p-dataTable>
Code: Select all
ngOnInit(): void {
this.refreshUI();
}
private refreshUI() {
this.service.getData('xxx').subscribe(
data => {
for (let row of data) {
this.logs.push({
id: row.id,
timestamp: new Date(row.logTime),
message: row.logMessage
});
}
}
);
}
Datatable change detection was rewritten for 4.0.0 and it doesn't refresh anymore if you change your array content.
You have to reassign the array every time you change it.
Quite a breaking change, yes. I myself have to use beta because I just don't have a time to go throw all of my datatables and change the way they work.
You have to reassign the array every time you change it.
Quite a breaking change, yes. I myself have to use beta because I just don't have a time to go throw all of my datatables and change the way they work.
Please look at this blog for more details https://www.primefaces.org/primeng-4-0-0-rc4-released/
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/
___________________
Sudheer Jonna
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/
___________________
Sudheer Jonna
-
- Information
-
Who is online
Users browsing this forum: No registered users and 91 guests