Freeze second column in data table using CSS - css

I have some data that shown in data table. I want to freeze two columns in data table (PPD Delivery Schedule and Check Opex).
The first column is working perfectly, but the second column is not freezing.
I don't have any idea, how to make it happen. Can you guys help me how to figure it out?
Here is my code
<style>
:root {
--screen-width: 1440px;
}
.rich-tabpanel-content-position {
table-layout: fixed;
}
table.dataTable {
display: block;
overflow: scroll;
}
.pbBody {
max-width: var(--screen-width);
overflow-x: auto;
}
.pbBody td.rich-tab-inactive,
.pbBody td.rich-tab-active {
background-color: #7998d2;
color: #FFFFFF;
font-weigth: bold;
background-image: none;
cursor: pointer;
}
.pbBody td.rich-tab-active {
background-color: #637fb2;
}
.dataTables_length {
margin-right: 10px;
}
table.dataTable tfoot th,
table.dataTable tfoot td {
padding-left: 10px;
padding-right: 10px;
}
.loadingMessage {
margin-bottom: 10px;
display: block;
}
#PlantOptions {
width: 50px;
}
thead th {
position: -webkit-sticky;
/* for Safari */
position: sticky;
top: 0;
}
thead th:first-child {
left: 1;
z-index: 1;
}
tbody th:first-child {
left: 0;
z-index: 1;
}
#columnA {
position: -webkit-sticky;
/* for Safari */
position: sticky;
left: 0;
background: #FFF;
border-right: 1px solid #CCC;
}
th.SecondColumn {
position: -webkit-sticky;
/* for Safari */
position: sticky;
left: 100px;
/* This is the width of first column, so second will stick to the right edge of the first column */
z-index: 999;
}
</style>
<table id="salesPlanTable" class="stripe row-border order-column" style="width:100%">
<thead>
<tr>
<th id="columnA">PPD Delivery Schedule</th>
<th id="columnA">Check Opex</th>
<th id="columnA">Sales Price</th>
<th id="columnA">Simulation Sales Price</th>
<th id="columnA">Variance Amount</th>/tr>
</thead>
<tbody>
<apex:repeat value="{!dataSalesPlan}" var="i">
<tr>
<th id="columnA">
<apex:input type="date" value="{!i.deliverySchedulePPD}">
<apex:actionSupport event="onblur" action="{!updateDeliverySchedule}" reRender="">
<apex:param name="salesPlanIndex" value="{!i.index}" assignTo="{!salesPlanIndex}" />
</apex:actionSupport>
</apex:input>
<apex:outputText styleClass="hidden" value="{0, date, MMMM d',' yyyy}">
<apex:param value="{!i.deliverySchedulePPD}" />
</apex:outputText>
</th>
<th class="SecondColumn">
<apex:inputCheckbox styleClass="checkOpex{!i.spd.ID} checkOpex {!i.spd.ID}" value="{!i.opex}">
<apex:actionSupport event="onchange" action="{!updateOpex}" reRender="">
<apex:param name="salesPlanIndex" value="{!i.index}" assignTo="{!salesPlanIndex}" />
</apex:actionSupport>
</apex:inputCheckbox>
<apex:outputText styleClass="hidden checkOpexOutput{!i.spd.ID}" value="{0}">
<apex:param value="{!i.opex}" />
</apex:outputText>
</th>
<td>
<apex:outputText styleClass="latestSalesPrice{!i.spd.ID}" value="{0, number}">
<apex:param value="{!i.latestSalesPriceDocument}" />
</apex:outputText>
</td>
<td>
<apex:input styleClass="simulationSalesPrice{!i.spd.ID}" onkeyup="changeSimulationSalesPrice(event, '{!i.spd.ID}')" value="{!i.simulationSalesPrice}">
<apex:actionSupport event="onblur" action="{!updateSimulationSalesPrice}" reRender="">
<apex:param name="salesPlanIndex" value="{!i.index}" assignTo="{!salesPlanIndex}" />
</apex:actionSupport>
</apex:input>
<apex:outputText styleClass="hidden simulationSalesPriceOutput{!i.spd.ID}" value="{0, number}">
<apex:param value="{!i.simulationSalesPrice}" />
</apex:outputText>
</td>
<td>
<apex:outputText styleClass="varianceAmount{!i.spd.ID}" value="{0, number}">
<apex:param value="{!i.VarianceAmount}" />
</apex:outputText>
</td>
</tr>
</apex:repeat>
</tbody>
</table>

Yes we can make second one also. Us id interested of class in td how you did for 1st one. I will work.

Related

Scaling element while keeping an attached pseudo-element in place and unscaled

In below code, the content inside the element should scale on hover (vertically centered scaling), but the attached absolute positioned pseudo-element (*) should stay in exactly the same place without any scaling. I my code the *-symbol unfortunately is scaling and altering it's position.
Note: While I can't change the HTML markup, I'm free to define the CSS.
table {
margin: 3rem;
}
td {
position: relative;
}
span {
display: inline-block;
}
td div span::before {
position: absolute;
content: '*';
top: -1rem;
left: -4rem;
right: -4rem;
text-align: center;
font-size: 80%;
}
div {
padding: 1rem;
background: lightgreen;
}
div:hover span {
transform: scale(2.6);
}
<table>
<tr>
<td>
<div><span>1</span></div>
</td>
<td>
<div><span>2</span></div>
</td>
<td>
<div><span>3</span></div>
</td>
<td>
<div><span>4</span></div>
</td>
<td>
<div><span>5</span></div>
</td>
</tr>
</table>
Attach the ::before to the div instead of the span:
table {
margin: 3rem;
}
td {
position: relative;
}
span {
display: inline-block;
}
td div::before {
position: absolute;
content: '*';
top: -1rem;
left: -4rem;
right: -4rem;
text-align: center;
font-size: 80%;
}
div {
padding: 1rem;
background: lightgreen;
}
div:hover span {
transform: scale(2.6);
}
<table>
<tr>
<td>
<div><span>1</span></div>
</td>
<td>
<div><span>2</span></div>
</td>
<td>
<div><span>3</span></div>
</td>
<td>
<div><span>4</span></div>
</td>
<td>
<div><span>5</span></div>
</td>
</tr>
</table>

Asp.Net Bootstrap reformat table for mobile media query without side scroll

I found this code here https://css-tricks.com/responsive-data-tables/ but for some reason it doesn't work as expected for my table.
I'm working inside Razor view.
Here is my table code:
<table class="table table-hover">
<thead>
<tr>
<th>
#Html.DisplayNameFor(model => model.FirstName)
</th>
<th>
<a asp-action="Index" asp-route-sortOrder="#ViewData["NameSortParm"]">#Html.DisplayNameFor(model => model.LastName)</a>
</th>
<th>
<a asp-action="Index" asp-route-sortOrder="#ViewData["EmailSortParm"]">#Html.DisplayNameFor(model => model.Email)</a>
</th>
</tr>
</thead>
<tbody>
#foreach (var item in Model)
{
<tr>
<td>
#Html.DisplayFor(modelItem => item.FirstName)
</td>
<td>
#Html.DisplayFor(modelItem => item.LastName)
</td>
<td>
#Html.DisplayFor(modelItem => item.Email)
</td>
</tr>
}
</tbody>
</table>
Here is CSS that I used:
table {
width: 100%;
border-collapse: collapse;
}
th {
background: #ccc;
font-weight: bold;
}
td, th {
padding: 6px;
border: 1px solid #ccc;
text-align: left;
}
/*Media Query*/
#media only screen and (max-width: 760px), (min-device-width: 768px) and (max-device-width: 1024px)
{
/* Force table to not be like tables anymore */
table, thead, tbody, th, td, tr {
display: block;
}
tr {
border: 1px solid #ccc;
}
td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
}
td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: nowrap;
}
/*Lable data*/
td:nth-of-type(1):before {
content: "FirstName";
}
td:nth-of-type(2):before {
content: "LastName";
}
td:nth-of-type(3):before {
content: "Email";
}
}
Result before media query:
Result after media query is triggered:
I cut down repetition code just to make it easier to read.
Any ideas where is the problem?
Oh never mind i guess i found the problem. position absolute is not needed:

Values are not sending to table when inserting details to the form

Something is wrong in my code because some parts of my code are not working properly. HTML and CSS both parts are working properly, just not the AngularJS. I need to send employee details to the below table when inserting values to the above form. Please fix my issue.
Below you can find my HTML, CSS, and AngularJS code.
var app = angular.module("myapp", []);
app.controller("CRUDoperation", function ($scope) {
$scope.Emplist = [];
$scope.AddData = function () {
var emp = {
Id: $scope.Emplist.length + 1,
Name: $scope.Name,
Salary: $scope.Salary
};
$scope.Emplist.push(emp);
ClearModel();
};
});
function ClearModel() {
$scope.Id = 0;
$scope.Name = '';
$scope.Salary = 0;
};
$scope.DeleteData = function (emp) {
var index = $scope.Emplist.indexOf(emp);
$scope.Emplist.splice(index, 1);
};
$scope.BindSelectedData = function (emp) {
$scope.Id = emp.Id;
$scope.Name = emp.Name;
$scope.Salary = emp.Salary;
};
$scope.UpdateData = function () {
$.grep($scope.Emplist, function (e) {
if (e.Id == $scope.Id) {
e.Name = $scope.Name;
e.Salary = $scope.Salary;
}
})
};
body {
background-image: url("back.jpg");
}
h1 {
text-align: center;
color: Crimson;
}
#save {
position: absolute;
left: 400px;
top: 240px;
width: 150px;
height: 40px;
color: white;
background-color: pink;
font-size: 18px;
}
#save:hover {
color: black;
background-color: Magenta;
cursor: pointer;
}
#update:hover {
color: black;
background-color: SaddleBrown;
cursor: pointer;
}
#update {
position: absolute;
left: 230px;
top: 240px;
width: 150px;
height: 40px;
color: white;
background-color: Peru;
font-size: 18px;
}
#del {
width: 110px;
height: 35px;
color: white;
background-color: SeaGreen;
font-size: 18px;
}
#del:hover {
color: black;
background-color: OrangeRed;
cursor: pointer;
}
#table1 {
position: absolute;
top: 300px;
left: 0px;
background-color: gray;
}
#table1:hover {
cursor: copy;
}
input[type=text] {
position: absolute;
top: 130px;
left: 150px;
width: 400px;
height: 35px;
}
input[type=number] {
position: absolute;
top: 180px;
left: 150px;
width: 400px;
height: 35px;
}
#hidden {
position: absolute;
top: 80px;
left: 150px;
width: 400px;
height: 35px;
background-color: gray:
}
#hidden:hover {
cursor: not-allowed;
}
span {
position: absolute;
top: 90px;
font-size: 25px;
}
span1 {
position: absolute;
top: 135px;
font-size: 25px;
}
span2 {
position: absolute;
top: 185px;
font-size: 25px;
}
<!DOCTYPE html>
<<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<meta charset="UTF-8">
<title>Angular Web App</title>
</head>
<body>
<h1>Employee Details</h1>
<div ng-app="myapp" ng-controller="CRUDoperation"></div>
<div class id="center">
<table>
<tr>
<td><span>ID</span></td>
<td><input type="text" id="hidden" disabled="disabled" placeholder="Auto Filled" ng-model="Id"></td>
</tr>
<tr>
<td>
<span1>Name</span1>
</td>
<td><input type="text" placeholder="Enter Employee Name here" ng-model="Name"></td>
</tr>
<tr>
<td>
<span2>Salary</span2>
</td>
<td><input type="number" placeholder="Enter Salary Amount here" ng-model="Salary"></td>
</tr>
<tr>
<td><input type="button" id=save ng-click="AddData()" value="Save Data"> </td>
</tr>
<tr>
<td><input type="button" id=update ng-click="UpdateData()" value="Update Data"> </td>
</tr>
</table>
<table border="2" id="table1" style="width:550px;">
<thead>
<th>ID</th>
<th>Name</th>
<th>Salary</th>
</thead>
<tr ng-click="BindSelectedData(Emp)" ng-repeat="Emp in Emplist">
<td>{{emp.Id}}</td>
<td>{{emp.Name}}</td>
<td>{{emp.Salary}}</td>
<td><input type="button" ng-click="DeleteData(Emp)" id=del value="Delete"></td>
</tr>
</table>
<table border="2" id="table1" style="width:550px;">
<thead>
<th>ID</th>
<th>Name</th>
<th>Salary</th>
</thead>
<tr ng-click="BindSelectedData(Emp)" ng-repeat="Emp in Emplist">
<td>{{emp.Id}}</td>
<td>{{emp.Name}}</td>
<td>{{emp.Salary}}</td>
<td><input type="button" ng-click="DeleteData(Emp)" id="del" value="Delete"></td>
</tr>
</table>
</body>
</html>
Angular uses camelCase + interpolation. So, instead of ng-thing, it's actually ngThing, and you also have to put parentheses and brackets around them. So, it would be
[(ngModel)]="blahblah"
[(ngRepeat)]="blahblah"
[(ngClick)]="blahblah"
etc
Also, you have <!DOCTYPE> twice. That may cause you problems as well.

100% height pseudo element on a table cell in IE

I am encountering an issue in IE9,10,11 where an ::after pseudo element will not fill 100% of the height of it's td parent.
If the first column in the second row had two lines of text, the pseudo element would fill the full height with no problem. So, I figured that the issue was happening because the td was not filling the height of the tr but that isn't the case.
The first screenshot is Chrome and the second is IE9
HTML
<table>
<tr>
<td>Two<br/>Lines</td>
<td>Two<br/>Lines</td>
</tr>
<tr>
<td>One Line</td>
<td>Two <br/>Lines</td>
</tr>
</table>
CSS
table td {
border-bottom: 1px solid;
}
table td:first-child {
position: relative;
}
table td:first-child::after {
position: absolute;
top: 0;
right: 0;
content: '';
width: 2px;
height: 100%;
display: block;
background-color: orange;
}
Codepen: http://codepen.io/cbier/full/BjpaqB/
P.S. I am using an ::after pseudo-element instead of borders for a special reason and it is a requirement
Thanks!
May be using a single pseudo element for the whole table ?
table {
overflow: hidden;
}
table td {
border-bottom: 1px solid;
}
table tr:first-child td:first-child {
position: relative;
}
table tr:first-child td:first-child:after {
position: absolute;
top: 0;
right: 0;
content: '';
width: 2px;
height: 1000px;
display: block;
background-color: orange;
}
<table>
<tr>
<td>Two<br/>Lines</td>
<td>Two<br/>Lines</td>
</tr>
<tr>
<td>One Line</td>
<td>Two <br/>Lines</td>
</tr>
</table>
An alternate way, with background : linear-gradient
table td {
border-bottom: 1px solid;
}
table td:first-child {
background-image: linear-gradient(270deg, orange 3px, transparent 3px);
}
<table>
<tr>
<td>Two<br/>Lines</td>
<td>Two<br/>Lines</td>
</tr>
<tr>
<td>One Line</td>
<td>Two <br/>Lines</td>
</tr>
</table>
You can use following code for it:
table td:first-child::after {
position: absolute;
top: 0;
right: 0;
content: '';
width: 2px;
height: 45px;
display: block;
background-color: orange;
}
it is giving same output in chromeas well as IE 9

table <td> tags not having a uniform and even size

I have a html table I am trying to build as formatting for a website banner and menu links. The menu links tags however won't stay at an even size no matter how much size and margin fiddling I do.
<table id="format_table">
<tr>
<th colspan=100>
LOGO
</th>
</tr>
<tr align="center">
<td>Home</td>
<td>Etc</td>
<td>Etc</td>
<td>Etc</td>
</tr>
<tr>
<td>
#RenderBody()
</td>
</tr>
</table>
table
{
background-color: White;
border: 1;
border-width: 1;
margin-left: auto;
margin-right: auto;
width: 85%;
}
th
{
text-align:center;
margin-left: auto;
margin-right: auto;
width: 80%;
}
td
{
text-align: center;
margin-left: auto;
margin-right: auto;
padding: 0 5 0 5px
}
Try this one:
td { width:100px; height:50px; }

Resources