Page 1 of 1

dataGrid not update if collection modify

Posted: 29 Apr 2016, 20:27
by microdeveloper
Hi i have successfully bind datagrid and it works fine but if i change the collection so datagrid cannot update automatically.

Re: dataGrid not update if collection modify

Posted: 29 Apr 2016, 20:48
by cagatay.civici
I couldn't replicate in my local test and checked out the code, change detection seems to be implemented properly.

Do you have paginator? Is it lazy loading datagrid? How do you modify the data?

Re: dataGrid not update if collection modify

Posted: 29 Apr 2016, 21:02
by microdeveloper
Modifications work perfectly if i update any record or etc, But when i add new record in the list so then Datagrid does not update.
This is my method

let cpt: Cptcode = new Cptcode();
cpt.code = event.data.Code;
cpt.description = event.data.Description;
this._CPTCode.push(cpt);

in above _CPTCode is the list which is binded to datagrid.

Re: dataGrid not update if collection modify

Posted: 02 May 2016, 02:23
by microdeveloper
Please suggest me i am stuck what should i do now.

Re: dataGrid not update if collection modify

Posted: 02 May 2016, 07:32
by cagatay.civici
I couldn't replicate so will ask my colleague to try the same, he will give an update.

Re: dataGrid not update if collection modify

Posted: 02 May 2016, 08:43
by DarthMaul
I couldnt replicate the issue either everything works fine locally.Do you have any configurations? because its updating the list as expected.

Re: dataGrid not update if collection modify

Posted: 02 May 2016, 14:06
by microdeveloper
Component Code is following.

<p-dataGrid style="background-color:white;" [(value)]="_CPTCode" [columns]="3">
<template #cpt>
<div class="divLink ui-grid ui-grid-responsive animated fadeIn" style="padding:0;">
<div class="ui-grid-row" (click)="OnClickCPT(cpt)">
<div class="ui-grid-col-3">
{{cpt.code}}
</div>
</div>
</div>
</template>
</p-dataGrid>

On Add Method

let cpt: Cptcode = new Cptcode();
cpt.code = event.data.Code;
cpt.description = event.data.Description;
this._CPTCode.push(cpt);