How to Center Align ng-Table Header? - angularjs

All ,
I am using ng-table for the Grid. I am using following code snippet to set the column .
<td data-title="'Access ID'" sortable="'accessID'" style="width:120px" class="text-center">{{people.accessID}}</td>
But I am not able to center align the Column Header but column data.
Here is the source code snippet for Access ID Header.
<th ng-repeat="column in $columns" ng-class="{ 'sortable': parse(column.sortable), 'sort-asc': params.sorting()[parse(column.sortable)]=='asc', 'sort-desc': params.sorting()[parse(column.sortable)]=='desc' }" ng-click="sortBy(column, $event)" ng-show="column.show(this)" ng-init="template=column.headerTemplateURL(this)" class="header sortable"> <!-- ngIf: !template --><div ng-if="!template" ng-show="!template" ng-bind="parse(column.title)" class="ng-binding ng-scope">Access ID</div><!-- end ngIf: !template --> <!-- ngIf: template --> </th>
Question is , How to center align the Header for a particular column in ng-table?

The answer submitted by #OpenUserX03 is almost perfect, except you have to wrap the class name in single quotes, like so:
<td data-title="'Access ID'" sortable="'accessID'" style="width:120px" class="text-center" header-class="'text-center'">{{people.accessID}}</td>

You can use the header-class attribute to set the class for - you guessed it - the header.
<td data-title="'Access ID'" sortable="'accessID'" style="width:120px" class="text-center" header-class="text-center">{{people.accessID}}</td>

i used to have the same issue how to align left my ng-table headers.
on the documentation of ng-table it does not say anything nor at the examples.
you have two ways to do this the fast and the more 'professional'
fast way:
open files ng-table/dist/ng-table.css and ng-table.min.css, according on which css file you use.
on the first line it manages the header,
.ng-table th {
text-align: center;/*just change that parameter to left/right*/
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
'professional' way: create a custom style and add it to your website css file ,like this :
.table thead th {
text-align: left;/*change that parameter to left/right*/
}
Hope helps, good luck.

To anyone who still has this issue, also OP, since he has not yet accepted an answer, this is how I do it. in your css (any .css)
table[ng-table] th {
text-align: left;
border-top: none;
}

Fix for ngTable
For those seeing this a year later. None of the above solutions worked for me. I added this to a custom css file:
.ng-table th {
text-align: center !important;
}
Which centered the content in the header (see images)
From this:
To this:

table .text-center {
text-align: center;
}
JSFiddle http://jsfiddle.net/BrTzg/411/

Related

How to Evenly Space Checkboxes, Even When Page is Resized

Thanks in advance for your help.
I need to ensure even vertical spacing between DIVS containing a checkbox + a labels inside a form -- even when the page is resized. The problem I'm having is that the labels are different lengths, so when the page is resized, the spacing between the DIVS is consistent, but I want the spacing to be even between the end of one label (which may be up to 3 lines long), and the start of the next.
I was reading about flexbox, and hoped this would be an appropriate method to handle. But it's not working as I expected, perhaps because I'm doing it wrong. Or perhaps because I'm using the checkbox hack for custom checkboxes, and that is interfering?
Here's my code:
CSS:
/* CUSTOM CHECKBOX CONTROLS */
input[type=checkbox].css-checkbox {
position:absolute;
z-index:-1000;
left:-1000px;
overflow: hidden;
clip: rect(0 0 0 0);
height:1px;
width:1px;
margin:-1px;
padding:0;
border:0;
}
input[type=checkbox].css-checkbox + label.css-label, input[type=checkbox].css-checkbox + label.css-label.clr {
padding-left:19px;
height:14px;
display:inline-block;
line-height:14px;
background-repeat:no-repeat;
background-position: 0 0;
font-size:16px;
vertical-align:middle;
cursor:pointer;
}
input[type=checkbox].css-checkbox:checked + label.css-label, input[type=checkbox].css-checkbox + label.css-label.chk {
background-position: 0 -14px;
}
label.css-label {
background-image:url(http://csscheckbox.com/checkboxes/u/csscheckbox_15092a7494cee0a8cdfe5f1e21e1e816.png);
-webkit-touch-callout: none; 212 247 8100
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* FLEXBOX CONTROLS */
.flex-container {
display:flex;
flex-direction:column;
height:450px;
align-items:baseline;
}
.flex-item {
margin:auto;
margin-left:0px;
flex-basis:0;
flex-shrink:1;
height:auto;
min-height:50px;
}
HTML:
<div class="flex-container">
<div class="flex-item"><input type="checkbox" name="checkboxG4" id="checkboxG4" class="css-checkbox" />
<label for="checkboxG4" class="css-label radGroup1"><p>News, Commentary, Research & Special Reports</p></label>
</div>
<div class="flex-item"><input type="checkbox" name="checkboxG5" id="checkboxG5" class="css-checkbox" />
<label for="checkboxG5" class="css-label radGroup1"><p>Get General Research that includes periodic Special Reports sent when a landmark market event occurs.</p></label>
</div>
</div>
sorry if this is answer is late but maybe this can still help you. Looking at the JFiddle link you provided here: Your JFiddle, the reason this is not working is because you have set the height of your labels to a fixed height of 14px (to work with the checkbox feature you implemented). You correctly set justify-content: space-around to do what you described, but if the content is always 14px regardless of how many lines it spans, then the space will remain the same no matter what. Since your checkbox feature requires this 14px height, you should instead apply this checkbox feature to a div nested inside the label, with the accompanying text outside this div, but still inside the label. Here is a JFiddle with the code I implemented to get this working.
The main HTML change is this:
<label for="checkboxG4" class="radGroup1">
<div class="css-label"></div>
<span>News, Commentary, Research & Special Reports</span>
</label>
instead of:
<label for="checkboxG4" class="css-label radGroup1">
<p>News, Commentary, Research & Special Reports</p>
</label>
and CSS changed to:
input[type=checkbox].css-checkbox + label div.css-label,
input[type=checkbox].css-checkbox + label div.css-label.clr {}
label div.css-label {}
instead of:
input[type=checkbox].css-checkbox + label.css-label,
input[type=checkbox].css-checkbox + label.css-label.clr {}
label.css-label {}

how to reduce the height of header in tabel view or grid view?

I am trying to make simple demo of grid view .In which I have header of title (having gray background) actually I need to reduce the height of title or headers of table which have gray background .can we add alternate color of rows ? please see the given image .It header or tittle is too small as compared to my plunker .Secondly there is alternate color in row .can we add that in my plunker .
http://plnkr.co/edit/7bSnk0fU0NBOF1GIwHSK?p=preview
.search.list-inset, .search.list-inset .item:first-child {
border-radius: 50px;
}
.search .item-input .icon {
font-size: 200%;
}
.gray-20 {
background-color: #eee;
}
#media (min-width: 600px) {
.search {
width: 50%;
margin-left:auto;
margin-right: auto;
}
}
.mrginrightleft{
margin-left:5%;
margin-right:15%;
}
.brd{
border: 1px solid grey;
}
here is my code![enter image description here][1]
Updated Plunker
How to style striped rows
There are two ways to do this. One is pure CSS using the :nth-child(even) or (odd) pseudo classes. You can add a class to your row and just use style it how you want, such as:
my-class:nth-child(even) .col {
background-color: blue;
}
But I did it differently to teach you something about ng-repeat. Yes, it's for a loop, but it has a bunch of special properties that it exposes for you. Two in particular are $odd and $even. As you might expect, $odd returns true if it is an odd iteration and $even is true when the index is an even number.
So, you can use these with ng-class as part of your expression. Here, I'm adding a class of odd-row:
<div class="row" ng-repeat="column in displayData | orderBy: sortval:reverse | filter: query" ng-class="{'odd-row':$odd}">
Then to make the styles, I added the following rule. I applied the background-color to the .col children so that the background would be contained within the borders that are applied on the .col elements.
.odd-row .col {
background-color: #eee;
}
EDIT:
Actually, you are correct, ng-style would be a third-way, but it doesn't apply a class, it applies inline styles. Therefore, you need to pass it an object with you styles, so for example (simplified):
ng-style="{'color': 'red'}"

I want to put the star mark as mandatory field in a vf page .I have tried but it is getting on the top of the form.please guide me..?

please help me that how to put star mark as mandatory field for account number,type ,industry,as mention in the given code.As I already tried but it is coming on the top of the form.please help me.I have already created style class and fields in account object .
In Visualforce if you are using apex:inputField you can use the built in required attribute to render the appropriate red bar in the HTML/CSS. Most other input controls also have the same attribute. E.g.
<apex:inputText value="{!inputValue}" id="theTextInput" required="true"/>
You can also manually include the required elements to get the same effect.
<apex:outputPanel layout="block" styleClass="requiredInput" >
<div class="requiredBlock"></div>
<apex:inputField value="{!someBinding}" label="The Label"/>
</apex:outputPanel>
Incidentally, the Salesforce Stackexchange is a great place to ask Salesforce specific questions.
Here is the CSS to change the default 'red Bar' to 'red Asterisk' in front of each required field:
.requiredInput .requiredBlock {background-color: transparent; }
.requiredInput .requiredBlock::before { display: block; content: "*"; font-size: 1.5em; font-weight: bold; color: #c00; margin-left: -4px; margin-top: -2px; }
Add the above CSS in your page.
Hope this helps :)

rich:calendar and popup width/size

With WebKit-based browser when I go with the mouse over the popup-header (where the month is defined) the entire popup "collapses/shrinks".
I went then to the richfaces showcase page to see if the problem exists there too, but there the popup width/size doesn't changes.
I look at the code and tried to set the width in mine too with style="width:200px", but there is no effect...
If I look with FireBug(F12) the element property width doesn't even appear:
element.style {
position: absolute;
z-index: 3;
left: 459px;
top: 225px;
}
And here is the calendar code:
<td style="font-size: 5pt; border: 0; min-width: 60px">
<rich:calendar id="startDate" value="#{detailModel.afterObject.startDate}"
datePattern="yyyy-MM-dd" enableManualInput="true"
style="width:200px"
disabled="#{detailModel.mode == detailModel.viewMode}">
<f:validateBean/>
</rich:calendar>
<h:messages for="startDate" style="color:red; font-size:12px;"/><br/>
</td>
Any suggestion why it doesn't work in my code?
The style applies to the invisible div that contains the input and the button, what you want to use is popupStyle or popupClass. See the docs.

Visual Force page help

I am trying to load values into VF input box based on the account selected from popup.
<apex:pageBlockSectionItem id="pageblocksectionitem5">
<apex:outputLabel value="Account Name"></apex:outputLabel>
<apex:panelGroup style="border: 0px solid Blue;" >
<apex:outputPanel layout="inline" style="background-color:#CC0000; padding-left: 3px; position: absolute; margin-left: 0px; margin-top: 2px; margin-right: 0px; height: 20px; border: 0px Red; " ></apex:outputPanel>
<input type="text" name="AccountName" id="Input12" style="margin-left: 5px; " /><img src="/s.gif" class="lookupIcon" onClick='window.open("/apex/xyz,"width=600,height=400,left=150,top=200,toolbar=1,status =1,");'/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem id="pageblocksectionitem3">
<apex:outputLabel value="Linea"></apex:outputLabel>
<apex:outputLabel value="{!linea}"></apex:outputLabel>
</apex:pageBlockSectionItem>
I need to populate linea from the custom field linea__c which is from Account object.. I can query to get the field value. But i need it to happen immediately after the account is selected. How can i do it?
Any pointers would be great...
Thanks
You'll need JavaScript actions... In fact probably best will be action and rerender attributes of most tags you'll see in the Visualforce Component Reference.
Please also have a look at this tutorial: http://wiki.developerforce.com/index.php/Force.com_Tutorial:_An_Introduction_to_Visualforce, especially part above the "Tutorial: Web Applications In A Jiffy". Similar thing (restructured to form new Cookbook: http://developer.force.com/cookbook/recipe/using-ajax-in-a-visualforce-page)
Last but not least - the Visualforce Developer Guide documentation PDF might be interesting for you - the chapter about "Creating a Wizard" (page 98 in the PDF) will be a nice (but a bit too full blown) example.

Resources