Data table Column style Error

UI Components for Angular
Post Reply
kumawat
Posts: 27
Joined: 11 Mar 2016, 15:26

25 Jul 2016, 12:06

Hello Guys,

I have recently upgraded to Angular2 RC4 and after that i am facing few errors in Primeng Components.

1) On Data table column, I want to set some custom style but now it throws exception


<p-dataTable [value]="GridOptions['rowData']" resizableColumns="true" [responsive]="true">
<div *ngFor="let col of GridOptions['columnDefs']">
<p-column [field]="col.field" [header]="col.header" [sortable]="true" [style]="col.style"></p-column>
</div>
</p-dataTable>


ColumnDefs item as like this,

GridOptions['columnDefs'].push({
header: "",
field: fieldStr,
style: "{'width':'50px', 'text-align': 'center'}",
hasDeleteButtonOnRows: true,
});


Error On style as follows,

platform-browser.umd.js:1900 ORIGINAL EXCEPTION: Cannot find a differ supporting object '{'width':'50px', 'text-align': 'center'}'

Error: Cannot find a differ supporting object '{'width':'50px', 'text-align': 'center'}'
at new BaseException (core.umd.js:4412)
at KeyValueDiffers.find (core.umd.js:7915)
at NgStyle.set [as rawStyle] (common.umd.js:2002)
at DebugAppView._View_DataTable4.detectChangesInternal (DataTable.template.js:689)
at DebugAppView.AppView.detectChanges (core.umd.js:12143)
at DebugAppView.detectChanges (core.umd.js:12247)
at DebugAppView.AppView.detectContentChildrenChanges (core.umd.js:12161)
at DebugAppView._View_DataTable3.detectChangesInternal (DataTable.template.js:540)
at DebugAppView.AppView.detectChanges (core.umd.js:12143)
at DebugAppView.detectChanges (core.umd.js:12247)




https://pl.vc/1lqkgt
Image

Can you please suggest why it appended signle quotes in style string?

Awaiting for your response.

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

25 Jul 2016, 19:01

Style should be an object, not a string;

Code: Select all

style: {'width':'50px', 'text-align': 'center'},

kumawat
Posts: 27
Joined: 11 Mar 2016, 15:26

26 Jul 2016, 09:56

Hi Optimus.prime,

Thank you for the help. It resolved my problem.

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

26 Jul 2016, 10:04

Glad to hear!

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 35 guests