Datatable custom renderer

UI Components for Angular
Post Reply
ReapeR
Posts: 12
Joined: 02 Mar 2016, 15:01

02 Mar 2016, 16:53

Is it (or will it be) possible to create a column with a custom template?

So far, i'm able to create a column without a null field, but there's no way to insert an HTML/template on it..

Code: Select all

this.cols = [
      {field: 'vin', header: 'Vin'},
      {field: 'brand', header: 'Brand'},
      {field: 'year', header: 'Year'},
      {field: 'color', header: 'Color'},
      {field: null, header: 'Actions'}
];
Thanks for you help!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

03 Mar 2016, 13:06

This was left out in 0.5, we'll do it very soon, just trying to come up with a decent solution these days so being worked on and it has high priority.

ReapeR
Posts: 12
Joined: 02 Mar 2016, 15:01

03 Mar 2016, 19:14

Great, thanks!
Hope we can see it in next release :D

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

05 Mar 2016, 03:07

I've managed to figure out a way but faced with this exception;

https://github.com/angular/angular/issues/7443

Waiting for angular team's comment.

Idea for DataTable is;

Code: Select all

<p-dataTable [value]="cars">
        <p-column field="vin" [sortable]="true"></p-column>
        <p-column field="brand" [sortable]="true">
            <template #col #rowData="rowData">
                  <span style="font-weight:bold">{{rowData[col.field]}}</span>
            </template>
        </p-column>
         <p-column>
             <template #col #rowData="rowData">
                 <button type="button" (click)="selectRow(rowData)">Edit</button>
             </template>
          </p-column>
</p-dataTable>
So default cell content can be customized using a template element.

Proof of concept worked except this annoying error mentioned above, it only happens in development mode, not in prod mode.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Mar 2016, 15:02

We've managed to find a solution so this feature will be available in 0.7 next week, here is preview of how it is used via template elements.

Image

ReapeR
Posts: 12
Joined: 02 Mar 2016, 15:01

09 Mar 2016, 15:43

Perfect! Many thanks!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

10 Mar 2016, 19:22


Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests