Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document rowStyleMap usage in DataTable #4658

Closed
TheParad0X opened this issue Dec 12, 2017 · 1 comment
Closed

Document rowStyleMap usage in DataTable #4658

TheParad0X opened this issue Dec 12, 2017 · 1 comment
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@TheParad0X
Copy link

Hi,

I am struggling with the rowStyleMap of the datatable. I would like to change the color of a row depending on its content. How can I do this ? I could not find any good example, and the documentation is a bit dire.

Cheers,
Tim

@Aarkon
Copy link

Aarkon commented Dec 14, 2017

I found the source code to be quite instructive: https://github.com/primefaces/primeng/blob/master/src/app/components/datatable/datatable.ts#L2602

Let's look at an example. In Angular, you define the StyleMap variable (e.g. named 'rowStyleMap') in the component like so (it's name is arbitrary though):

rowStyleMap = {'black': 'strong'};

In the html containing the datatable, use the map like this:

<p-dataTable .. [rowStyleMap]="rowStyleMap" dataKey="color">"

Now, whenever a row has the string 'black' in it's column 'color', the styling will be applied. \m/

@cagataycivici cagataycivici changed the title How to use rowStyleMap in a DataTable ? Document rowStyleMap usage in DataTable Dec 19, 2017
@cagataycivici cagataycivici self-assigned this Dec 19, 2017
@cagataycivici cagataycivici added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Dec 19, 2017
@cagataycivici cagataycivici added this to the 5.1.0-RC1 milestone Dec 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

3 participants