- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 04:41 AM - edited 02-23-2024 06:58 AM
Hello,
I am using the out of the box widget "Data Table from Instance" on our portal to show a list of compliance controls from the "sn_compliance_control"-table, in the backend the list has a green dot on the status field, if the value is "Compliant" and a red dot on the status field if the value of a control is "Non-compliant", however these red and green dots are not present on the list when I present it on the portal through the widget initially mentioned.
How can I achieve this ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 08:31 AM
Hi @mausser
Replace the complete <tbody></tbody> from line 49 to 54 with below lines. It will work
<tbody>
<tr ng-repeat="item in data.list track by item.sys_id">
<td role="{{$first ? 'rowheader' : 'cell'}}" class="pointer sp-list-cell" ng-class="{selected: item.selected}" ng-click="go(item.targetTable, item)" ng-repeat="field in ::data.fields_array" data-field="{{::field}}" data-th="{{::data.column_labels[field]}}">
<a href="javascript:void(0)" ng-if="$first" aria-label="${Open record}: {{::item[field].display_value}}">
<span ng-if="item[field].type === 'user_image'"><img class="user_image" src="{{item[field].display_value}}"/></span>
<span ng-if="item[field].type !== 'user_image'">{{::item[field].display_value | limitTo : item[field].limit}}{{::item[field].display_value.length > item[field].limit ? '...' : ''}}</span>
</a>
<span ng-if="!$first">
<span class="dot" ng-class="{'compliant': item[field].display_value === 'Compliant', 'non-compliant': item[field].display_value === 'Non Compliant'}" style="margin-right: 5px;"></span>
<span ng-if="item[field].type === 'user_image'"><img class="user_image" src="{{item[field].display_value}}"/></span>
<span ng-if="item[field].type !== 'user_image'">{{::item[field].display_value | limitTo : item[field].limit}}{{::item[field].display_value.length > item[field].limit ? '...' : ''}}</span>
</span>
</td>
</tr>
</tbody>
Please Accept as Solution & mark helpful !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 06:37 AM
Hello Atul,
We already have the red / green dot in the backend on the list, however I want this as well on the list when I show it on the portal using the "Data Table from Instance"-widget, this widget shows the list fine but does not include the red / green dot as seen in the backend
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 06:48 AM
Hi @mausser ,
Firstly, you need to clone the widget & use it. After cloning, you have to modify the <tr> tag as below for status column.
<div class="status">
<span class="dot" ng-class="{'compliant': item.status === 'Compliant', 'non-compliant': item.status === 'Non-Compliant'}"></span> {{item.status}}
</div>
CSS
.dot {
width: 10px;
height: 10px;
border-radius: 50%;
display: inline-block;
margin-right: 5px;
}
.compliant {
background-color: green;
}
.non-compliant {
background-color: red;
}
Please mark as helpful and Accepted as Solution if it suffices your requirement !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 06:53 AM - edited 02-23-2024 06:55 AM
How does above code fit in with the data table widget ? I have cloned that widget, however looking at the code I am not sure where to add the code you provided to make sure it only shows the red dot / green dot on the field where it says "Non-compliant" / "Compliant"
This is where the table rows are being populated in the span:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 07:06 AM
Hi @mausser ,
After cloning the data table widget, in line 51 replace add this extra ng-class
ng-class="{'compliant': item[field].display_value === 'Compliant', 'non-compliant': item[field].display_value === 'Non-Compliant'}"
and add the below CSS to css section
.compliant {
background-color: green;
width: 10px;
height: 10px;
border-radius: 50%;
display: inline-block;
margin-right: 5px;
}
.non-compliant {
background-color: red;
width: 10px;
height: 10px;
border-radius: 50%;
display: inline-block;
margin-right: 5px;
}
Please mark as helpful and Accepted as Solution if it suffices your requirement !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 07:11 AM
Hello,
So is it line 51 in below image I have to change? do i need to replace the existing ng-class or simply add it?