Cell Renderer callback

UI Components for Angular
Post Reply
marcob
Posts: 3
Joined: 18 Jul 2019, 09:45

18 Jul 2019, 09:57

Hi All,
In my old software, I use ui-grid. Now I use p-table. I have a little problem; when I render some cells i want to execute callback for formatting value. Example:

Code: Select all

    <td class="ui-resizable-column" class="myclass" *ngIf="col.hidden == false">
                        {{rowData[col.field]}}    <---- Here I should call the callback
     </td>

Code: Select all

       function callback(column, rowData) {
           if (column.hasfunction) {
               return columns.cbfunction(rowData[col.field])
           } else 
            {
               return rowData[col.field];
            }
       }
It's possibile to make it?
thank's at all.
MarcoB

yigitfindikli
Posts: 339
Joined: 08 Aug 2018, 14:09

22 Jul 2019, 14:45

marcob wrote:
18 Jul 2019, 09:57
Hi All,
In my old software, I use ui-grid. Now I use p-table. I have a little problem; when I render some cells i want to execute callback for formatting value. Example:

Code: Select all

    <td class="ui-resizable-column" class="myclass" *ngIf="col.hidden == false">
                        {{rowData[col.field]}}    <---- Here I should call the callback
     </td>

Code: Select all

       function callback(column, rowData) {
           if (column.hasfunction) {
               return columns.cbfunction(rowData[col.field])
           } else 
            {
               return rowData[col.field];
            }
       }
It's possibile to make it?
thank's at all.
MarcoB
Hi,
Maybe you can try this;

html;

Code: Select all

<ng-template pTemplate="body" let-rowData let-columns="columns">
            <tr>
                <td *ngFor="let col of columns">
                     {{callback(rowData,col)}}
                </td>
            </tr>
        </ng-template>
ts;

Code: Select all

callback(column, rowData) {
           if (column.hasfunction) {
               return columns.cbfunction(rowData[col.field])
           } else 
            {
               return rowData[col.field];
            }
}
Best Regards.

marcob
Posts: 3
Joined: 18 Jul 2019, 09:45

01 Aug 2019, 12:07

Thanks a lot
Work perfectly.
Best Regards


yigitfindikli wrote:
22 Jul 2019, 14:45
marcob wrote:
18 Jul 2019, 09:57
Hi All,
In my old software, I use ui-grid. Now I use p-table. I have a little problem; when I render some cells i want to execute callback for formatting value. Example:

Code: Select all

    <td class="ui-resizable-column" class="myclass" *ngIf="col.hidden == false">
                        {{rowData[col.field]}}    <---- Here I should call the callback
     </td>

Code: Select all

       function callback(column, rowData) {
           if (column.hasfunction) {
               return columns.cbfunction(rowData[col.field])
           } else 
            {
               return rowData[col.field];
            }
       }
It's possibile to make it?
thank's at all.
MarcoB
Hi,
Maybe you can try this;

html;

Code: Select all

<ng-template pTemplate="body" let-rowData let-columns="columns">
            <tr>
                <td *ngFor="let col of columns">
                     {{callback(rowData,col)}}
                </td>
            </tr>
        </ng-template>
ts;

Code: Select all

callback(column, rowData) {
           if (column.hasfunction) {
               return columns.cbfunction(rowData[col.field])
           } else 
            {
               return rowData[col.field];
            }
}
Best Regards.

yigitfindikli
Posts: 339
Joined: 08 Aug 2018, 14:09

06 Aug 2019, 09:17

marcob wrote:
01 Aug 2019, 12:07
Thanks a lot
Work perfectly.
Best Regards


yigitfindikli wrote:
22 Jul 2019, 14:45
marcob wrote:
18 Jul 2019, 09:57
Hi All,
In my old software, I use ui-grid. Now I use p-table. I have a little problem; when I render some cells i want to execute callback for formatting value. Example:

Code: Select all

    <td class="ui-resizable-column" class="myclass" *ngIf="col.hidden == false">
                        {{rowData[col.field]}}    <---- Here I should call the callback
     </td>

Code: Select all

       function callback(column, rowData) {
           if (column.hasfunction) {
               return columns.cbfunction(rowData[col.field])
           } else 
            {
               return rowData[col.field];
            }
       }
It's possibile to make it?
thank's at all.
MarcoB
Hi,
Maybe you can try this;

html;

Code: Select all

<ng-template pTemplate="body" let-rowData let-columns="columns">
            <tr>
                <td *ngFor="let col of columns">
                     {{callback(rowData,col)}}
                </td>
            </tr>
        </ng-template>
ts;

Code: Select all

callback(column, rowData) {
           if (column.hasfunction) {
               return columns.cbfunction(rowData[col.field])
           } else 
            {
               return rowData[col.field];
            }
}
Best Regards.
Glad to hear, always happy to help!
Best Regards.

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests