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

Question: Data-Table with conditional text and icon in its TableItem #2797

Open
affanmustafa opened this issue Jan 17, 2024 · 3 comments
Open
Labels
component: Table For Table issues question Further information is requested Waiting for author's response

Comments

@affanmustafa
Copy link

In the website there is a table like this and I am trying to replicate the "Status" column where I can have either "Active" or "Disabled" with the green and grey circles to indicate status. I cannot find the code for this anywhere either.
I can set the headers like this:

tableModel.header = [
  new TableHeaderItem({ data: 'Status' }),
  new TableHeaderItem({ data: 'Name' }),
  new TableHeaderItem({ data: 'Attribute' }),
];

And then populate these fields like this:

tableModel.data = [
  new TableItem({ data: service.status }),
  new TableItem({ data: service.name }),
  new TableItem({ data: service.attribute }),
 ];

Like how it can be seen in the screenshot, I want either "Available 🟢" or "Disabled 🔴 " to be displayed. Another possible implementation that could work for me is adding a Green or Grey button based on the value of status.

I haven't been able to find relevant code in the documentation so far so was hoping for some help here. Thank you.

Screenshot_2024-01-17_at_5 44 40_PM
@tay1orjones
Copy link
Member

@affanmustafa Are you using Angular, Vue, React, or Web Components?

@tay1orjones
Copy link
Member

It looks like you might be using carbon-components-angular, I'm going to transfer this issue to their repo.

@tay1orjones tay1orjones transferred this issue from carbon-design-system/carbon-website Feb 22, 2024
@Akshat55
Copy link
Contributor

@affanmustafa, you have to pass in templates to customize the table columns as such:

<ng-template #customTableItemTemplate let-data="data">

Here is a live demo of the above: https://angular.carbondesignsystem.com/?path=/story/components-table--with-expansion

@Akshat55 Akshat55 added question Further information is requested component: Table For Table issues Waiting for author's response labels Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Table For Table issues question Further information is requested Waiting for author's response
Projects
Status: ⏱ Backlog
Development

No branches or pull requests

3 participants