Issues when try to apply css class on rows - html

I've got this table:
<table id="mytable" st-safe-src="dataSetREST" st-table="displayed" class="table table-responsive portlet-body panel-body">
<thead>
<tr >
<th >A</th>
<th >B</th>
<th >C</th>
<th >D</th>
<th >E</th>
<th >F</th>
<th >G</th>
<th >H</th>
</tr>
</thead>
<tbody data-ng-dblclick="scrollTo()">
<tr data-ng-repeat="row in displayed" st-select-row="row" st-select-mode="single" data-ng-class="{'selected':$index == selectedRow}" data-ng-click="setClickedRow($index)">
<td data-ng-click="$parent.selData(row);">{{$index}}</td>
<td data-ng-click="$parent.selData(row);">{{row.asd}}</td>
<td data-ng-click="$parent.selData(row);">{{row.sad}}</td>
<td data-ng-click="$parent.selData(row);">{{row.dsa}}</td>
<td data-ng-click="$parent.selData(row);">{{row.das}}</td>
<td data-ng-click="$parent.selData(row);">{{row.sda}}</td>
<td data-ng-click="$parent.selData(row);">{{row.ads}}</td>
<td data-ng-click="$parent.selData(row);">{{row.etc}}</td>
</tr>
</tbody>
</table>
I need to apply a background color on the selected row. In the controller I added this:
$scope.selectedRow = null;
$scope.setClickedRow = function(index){
$scope.selectedRow = index;
}
It should work since in data-ng-click I send the index to the method, but it didn't enter the method (or at least didnt print a console.log() placed inside). Here the css class:
.selected {
background-color: #67BBED;
}

check this fiddle it's working great http://jsfiddle.net/linkolen/tq31h4bw/#base
angular.module('myApp', []);
function TestCtrl($scope) {
$scope.selectedRow = null;
$scope.displayed = [{asd:3},{asd:3},{asd:3},{asd:3},{asd:3},{asd:3}]
$scope.setClickedRow = function(index){
$scope.selectedRow = index;
}
}
.selected {
background-color: #67BBED;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="TestCtrl">
<table id="mytable" st-safe-src="dataSetREST" st-table="displayed" class="table table-responsive portlet-body panel-body">
<thead>
<tr >
<th >A</th>
<th >B</th>
<th >C</th>
<th >D</th>
<th >E</th>
<th >F</th>
<th >G</th>
<th >H</th>
</tr>
</thead>
<tbody data-ng-dblclick="scrollTo()">
<tr data-ng-repeat="row in displayed" st-select-row="row" st-select-mode="single" data-ng-class="{'selected':$index == selectedRow}" data-ng-click="setClickedRow($index)">
<td data-ng-click="$parent.selData(row);">{{$index}}</td>
<td data-ng-click="$parent.selData(row);">{{row.asd}}</td>
<td data-ng-click="$parent.selData(row);">{{row.sad}}</td>
<td data-ng-click="$parent.selData(row);">{{row.dsa}}</td>
<td data-ng-click="$parent.selData(row);">{{row.das}}</td>
<td data-ng-click="$parent.selData(row);">{{row.sda}}</td>
<td data-ng-click="$parent.selData(row);">{{row.ads}}</td>
<td data-ng-click="$parent.selData(row);">{{row.etc}}</td>
</tr>
</tbody>
</table>
<div>

You can use ternary operator in expressions. Just give a try
<tr data-ng-repeat="row in displayed" st-select-row="row" st-select-mode="single" data-ng-click="selectedRow = $index" data-ng-class="$index == selectedRow ? 'selected' : ' '" >
I think your ng-click works later and you're applying class first.

Related

edit multiple rows data from text and table using same button in jquery 3.5

I want to enable editing multiple data field after clicking the edit button. There are multiple data need to change. I want to click on a cell (col/row) and that cell value will change to a textbox (editable). After the user edit the value, it will save the each edited data.
Here is the code snippet...
<div class="table-responsive">
<table class="table table-bordered table-dark">
<thead>
<tr>
<th scope="col">Personal Account</th>
<th scope="col">Beginning</th>
<th scope="col">End</th>
<th scope="col">Returns*</th>
<th scope="col">S&P 500***</th>
<th scope="col">Nasdaq***</th>
</tr>
</thead>
<tbody>
<tr class="table-primary input-data">
<td>Inception</td>
<td class="start-date" readonly='readonly'>7/31/2008</td>
<td class="end-date" readonly='readonly'>12/1/2022</td>
<td>22.69%</td>
<td>15.69%</td>
<td>27.87%</td>
</tr>
<tr class="table-primary input-data">
<td>Last 12 months</td>
<td class="start-date">12/31/2021</td>
<td class="end-date">12/1/2022</td>
<td>-31.90%</td>
<td>-15.99%</td>
<td>-29.41%</td>
</tr>
<tr class="table-primary input-data">
<td>Last 3 years</td>
<td class="start-date">12/31/2019</td>
<td class="end-date">12/1/2022</td>
<td>15.39%</td>
<td>9.10%</td>
<td>9.72%</td>
</tr>
<tr class="table-primary input-data">
<td>Last 5 years</td>
<td class="start-date">12/31/2017</td>
<td class="end-date">12/1/2022</td>
<td>14.95%</td>
<td>10.85%</td>
<td>13.71%</td>
</tr>
</tbody>
</table>
</div>
I want to use the latest version of jquery and ajax.
$('#edit-record').click(function() {
$(this).hide();
$('#save-data, #cancel').show();
if (edit-record {
$(this).prop('contenteditable', true).css({
'background': '#fff',
'color': '#000'
})
} else {
$(this).prop('contenteditable', false).removeAttr("style");
}
});
$('#cancel').click(function() {
$('#edit-record').show();
$('#save-data, #cancel').hide();
});
$('#save-data').click(function() {
$(this).hide();
$('#cancel').hide();
$('#edit-record').show();
});

Changing Raw Background Color

I would like to change the background color of the raw but it wont change
i have typed but still wont change <tr class="bg-green text-white">
<table border="0" class="table-striped" style="width:100%;table-layout:fixed">
<thead>
<tr class="bg-green text-white">
<th style="text-align:center">الترتيب</th>
<th style="text-align:center">النادي</th>
<th style="text-align:center">لعب</th>
<th style="text-align:center">فاز</th>
<th style="text-align:center">تعادل</th>
<th style="text-align:center">خسر</th>
<th class="d-none d-sm-table-cell" style="text-align:center">له</th>
<th class="d-none d-sm-table-cell" style="text-align:center">عليه</th>
<th style="text-align:center">فارق</th>
<th style="text-align:center">نقاط</th>
</tr>
</thead>
</table>
If you are using bootstrap you can use some common class to change the background color of the row. like-
<!-- On rows -->
<tr class="table-active">...</tr>
<tr class="table-primary">...</tr>
<tr class="table-secondary">...</tr>
<tr class="table-success">...</tr>
<tr class="table-danger">...</tr>
<tr class="table-warning">...</tr>
<tr class="table-info">...</tr>
<tr class="table-light">...</tr>
<tr class="table-dark">...</tr>
<!-- On cells (`td` or `th`) -->
<tr>
<td class="table-active">...</td>
<td class="table-primary">...</td>
<td class="table-secondary">...</td>
<td class="table-success">...</td>
<td class="table-danger">...</td>
<td class="table-warning">...</td>
<td class="table-info">...</td>
<td class="table-light">...</td>
<td class="table-dark">...</td>
</tr>
Bootstrap Ref
But if you are trying to change using only html and css, then you can try it like this.
tr{
background-color: blue;
}

Trying to apply CSS text decoration after input checkbox is checked

I am having issue trying to apply a CSS style to a sibling element after an input of checkbox has been checked. My goal is to apply the text-decoration of line-through and text-decoraction-color red to the sibling element.
DEMO: enter link description here
input:checked + td.p1Amount {
text-decoration: line-through;
text-decoration-color: red;
}
<table class="table table-striped table-bordered table-hover table-sm table-responsive">
<thead>
<tr>
<th scope="col">Item</th>
<th scope="col">Due Date</th>
<th scope="col">Paid</th>
<th scope="col">Amount</th>
<th scope="col">Notes</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Utility</th>
<td>05/15/2020</td>
<td><input type="checkbox"></td>
<td class="p1Amount">$1.00</td>
<td>Confirmation #5477ff59de</td>
</tr>
</tbody>
</table>
Am I not using the right CSS selector to select the sibling after the checkbox has been checked?
you can do it by vanilla js
document.querySelector(".checkbox").onchange = function(){
var check = document.querySelector("input").checked;
if(check == true){
document.querySelector(".p1Amount").style.textDecoration = "line-through";
document.querySelector(".p1Amount").style.textDecorationColor = "red";
}else {
document.querySelector(".p1Amount").style.textDecoration = null;
document.querySelector(".p1Amount").style.textDecorationColor = null;
}
} ;
<table class="table table-striped table-bordered table-hover table-sm table-responsive">
<thead>
<tr>
<th scope="col">Item</th>
<th scope="col">Due Date</th>
<th scope="col">Paid</th>
<th scope="col">Amount</th>
<th scope="col">Notes</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Utility</th>
<td>05/15/2020</td>
<td><input class="checkbox" type="checkbox"></td>
<td class="p1Amount">$1.00</td>
<td>Confirmation #5477ff59de</td>
</tr>
</tbody>
</table>
I used JQuery. Please Try this...
(function ($) {
$(document).ready(function(){
$(".check").click(function(){
if($(".check").prop('checked')){
$(".p1Amount").css("text-decoration","line-through");
$(".p1Amount").css("text-decoration-color","red");
}else{
$(".p1Amount").css("text-decoration","");
$(".p1Amount").css("text-decoration-color","");
}
});
});
}(jQuery));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table class="table table-striped table-bordered table-hover table-sm table-responsive">
<thead>
<tr>
<th scope="col">Item</th>
<th scope="col">Due Date</th>
<th scope="col">Paid</th>
<th scope="col">Amount</th>
<th scope="col">Notes</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Utility</th>
<td>05/15/2020</td>
<td><input type="checkbox" class="check"></td>
<td class="p1Amount">$1.00</td>
<td>Confirmation #5477ff59de</td>
</tr>
</tbody>
</table>

'How to add' mouseover and mouseout on a <tr>?

I've got a table that I need three different links to show up on the specific row that the mouse is hovering over. The links are "View", "Edit", and "Trigger Now".
I need this event to happen only on the sessions table.
Here's my current HTML:
<div>
<h1>Manage Workflows</h1>
</div>
<div class="tablez">
<table class="table table-hover" id = "groups">
<thead>
<tr>
<th scope="col">Groups</th>
</tr>
</thead>
<tbody>
<tr *ngFor = "let row of rows" (click) = "onRowClick(row.id)">
<td class="data">{{row.group}}</td>
</tr>
</tbody>
</table>
<table class="table" id = "sessions">
<thead>
<tr>
<th scope="col">Sessions</th>
<th scope="col" id = "trigger">Next Trigger</th>
</tr>
</thead>
<tbody>
<tr *ngFor = "let row of tableTwo">
<td scope="row">{{row.session}}</td>
<td scope="row" id = "trigger" >{{row.nextTrigger}}</td>
</tr>
</tbody>
</table>
</div>
You can use mouseover event of the angular
<tr *ngFor = "let row of tableTwo" (mouseover)="showLinks=true" (mouseout)="showLinks=false" >
<td scope="row">{{row.session}}</td>
<td scope="row" id = "trigger" >{{row.nextTrigger}} </td>
<td *ngIf="!showLinks" scope="row"> View Edit Trigger Now links </td>
</tr>

Html table not working on internet explorer

My table works perfectly on chrome and firefox but not working on Internet Explorer. Any idea what causes it ?
Could it be the problem about angular.js ? or just I.E renders tables differently ?
Is there any way to fix it ?
<div class="dashboard-container">
<div class="dashboard-container_subcontainer">
<table *ngIf="user && user.therapists" class="table table-bordered">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First name</th>
<th scope="col">Last name</th>
<th scope="col">Email</th>
<th scope="col">Country</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody *ngIf="sortedList">
<tr *ngFor="let therapist of sortedList; let i = index" class="clickable" (click)="toggleRowColor(i); setTherapist(therapist)" [ngClass]="{'border-green': i == selectedRow}">
<th class="smallcolmn" scope="row">{{i+1}}</th>
<td class="biggercolmn">{{therapist.firstName}}</td>
<td class="biggercolmn">{{therapist.lastName}}</td>
<td class="biggercolmn">{{therapist.email}}</td>
<td class="biggercolmn">{{therapist.country}}</td>
<td class="biggercolmn" [ngClass]="{'background-blue': therapist.status === TherapistStatus.REGISTERED, 'background-lightBlue': therapist.status === TherapistStatus.READY_FOR_TEST,
'txt-blue': therapist.status === TherapistStatus.CERTIFIED_FOR_APP}">{{constantService.status[therapist.status]}}</td>
</tr>
</tbody>
<tbody *ngIf="!sortedList">
<tr *ngFor="let therapist of therapistList; let i = index" class="clickable" (click)="toggleRowColor(i); setTherapist(therapist)" [ngClass]="{'border-green': i == selectedRow}">
<th class="smallcolmn" scope="row">{{i+1}}</th>
<td class="biggercolmn">{{therapist.firstName}}</td>
<td class="biggercolmn">{{therapist.lastName}}</td>
<td class="biggercolmn">{{therapist.email}}</td>
<td class="biggercolmn">{{therapist.country}}</td>
<td class="biggercolmn" [ngClass]="{'background-blue': therapist.status === TherapistStatus.REGISTERED, 'background-lightBlue': therapist.status === TherapistStatus.READY_FOR_TEST,
'txt-blue': therapist.status === TherapistStatus.CERTIFIED_FOR_APP}">{{constantService.status[therapist.status]}}</td>
</tr>
</tbody>
</table>
</div>
<app-info-container *ngIf="therapist && isOnline" class="infoContainer" (isInfoBoxHidden)='resetSelectedTherapist()' [chosenTherapist] = "therapist"></app-info-container>
<div class="noInternetConnection"*ngIf="!isOnline">No online connection available. Please reconnect.</div>
</div>