overriding primefaces 3.1 css for datatable - css

I am trying to override the css classes from primefaces 3.1, I was looking for a pattern for the class name to override.
I tried:
.ui-datatable table {}
.ui-datatable .ui-datatable-header,.ui-datatable .ui-datatable-footer {}
.ui-datatable .ui-datatable-header {}
.ui-datatable th,.ui-datatable tfoot td {}
.ui-datatable .ui-datatable-data td,.ui-datatable .ui-datatable-data-empty td{}
But only the rows content got centralized but was not able to change header bgcolor and other stuff.
Then I realized that may be the classes I overwrote might not have been used.
Surprisingly, I found the generated source code are not using these as class...
<div id="form:j_id1915418705_722af8cd" class="ui-datatable ui-widget">
<table role="grid"><thead><tr role="row">
<th id="form:j_id1915418705_722af8cd:j_id1915418705_722af894" class="ui-state-default" role="columnheader">
<div class="ui-dt-c">
<span><span class="outputText">Model</span></span>
</div>
</th>
<th id="form:j_id1915418705_722af8cd:j_id1915418705_722af942" class="ui-state-default" role="columnheader">
<div class="ui-dt-c">
<span><span class="outputText">Color</span></span>
</div>
</th></tr></thead><tfoot></tfoot>
<tbody id="form:j_id1915418705_722af8cd_data" class="ui-datatable-data ui-widget-content">
<tr data-ri="0" data-rk="BMW" class="ui-widget-content ui-datatable-even" role="row" aria-selected="false">
<td role="gridcell">
<div class="ui-dt-c">
<span class="outputText">BMW</span>
</div>
</td>
<td role="gridcell">
<div class="ui-dt-c">
<span class="outputText">Black</span>
</div>
</td>
</tr>
<tr data-ri="1" data-rk="Audi" class="ui-widget-content ui-datatable-odd" role="row" aria-selected="false">
<td role="gridcell">
<div class="ui-dt-c">
<span class="outputText">Audi</span>
</div>
</td>
<td role="gridcell">
<div class="ui-dt-c">
<span class="outputText">White</span>
</div>
</td>
</tr>
</tbody>
</table><input type="hidden" id="form:j_id1915418705_722af8cd_selection" name="form:j_id1915418705_722af8cd_selection" value="" autocomplete="off" />
Can somebody tell me how to I be able to change table headers, borders, alternate rows color...
Can somebody provide me a pattern for How to know what class in PF to override looking at the generted source code.
Thanks in advance.

First of the classes are included here in the markup:
<div id="form:j_id1915418705_722af8cd" class="ui-datatable ui-widget">
The other child classes automatically apply themselves to the other elements.
Your custom CSS may actually be overridden by the Primefaces CSS styles if you are including these styles in a seperate CSS file linked from head.
To make sure that your custom CSS applies itself to the page try adding the custom CSS inline to the page body and see if it applies then.

Related

descendant selector not working for .v-data-table th {*some style*}

I have a v-data-table with table headers and the styling is inside the .vue component. When I use the following style
.v-data-table-header th {
white-space: nowrap;
}
Nothing happens to the table headers. I have also tried other css like background and text colors and nothing is happening. I checked the dev tools and there are definitely th elements and it doesn't seem like the style is being overridden by anything since it's not even showing up in the styles tab of the dev tools. If i just use .v-data-table-header the style is applied. What could be going on here?
edit:
here is the vue code
<v-expansion-panel>
<v-expansion-panel-header>
Example header
</v-expansion-panel-header>
<v-expansion-panel-content>
<v-data-table
:headers="someHeaders"
:items="someItems"
/>
</v-expansion-panel-content>
</v-expansion-panel>
Here is the html for the table:
<div class="v-expansion-panel-content__wrap">
<div data-v-7037ec41="" class="v-data-table v-data-table--has-bottom theme--light">
<div class="v-data-table__wrapper">
<table>
<colgroup>
<col class="">
<col class="">
<col class="">
</colgroup>
<thead class="v-data-table-header">
<tr>
<th role="columnheader" scope="col" aria-label="Name: Not sorted. Activate to sort ascending."
aria-sort="none" class="text-start sortable"><span>Name</span><i aria-hidden="true"
class="v-icon notranslate v-data-table-header__icon material-icons theme--light"
style="font-size: 18px;">arrow_upward</i></th>
<th role="columnheader" scope="col" aria-label="Path: Not sorted. Activate to sort ascending."
aria-sort="none" class="text-start sortable"><span>Path</span><i aria-hidden="true"
class="v-icon notranslate v-data-table-header__icon material-icons theme--light"
style="font-size: 18px;">arrow_upward</i></th>
<th role="columnheader" scope="col"
aria-label="Message: Not sorted. Activate to sort ascending." aria-sort="none"
class="text-start sortable"><span>Message</span><i aria-hidden="true"
class="v-icon notranslate v-data-table-header__icon material-icons theme--light"
style="font-size: 18px;">arrow_upward</i></th>
</tr>
</thead>
<tbody>
<tr class="">
<td class="text-start">r3_ibmmq_jms_0.1</td>
<td class="text-start">Routes/MICROSERVICE</td>
<td class="text-start">cMQConnectionFactory component
"cMQConnectionFactory_1":MQTT_RECONNECT_DELAY of cMQConnectionFactory was changed to 10</td>
</tr>
<tr class="">
<td class="text-start">r4_ibmq_jms_job_0.1</td>
<td class="text-start">Routes/MICROSERVICE</td>
<td class="text-start">cMQConnectionFactory component
"cMQConnectionFactory_1":MQTT_RECONNECT_DELAY of cMQConnectionFactory was changed to 10</td>
</tr>
</tbody>
</table>
</div>
<div class="v-data-footer">
<div class="v-data-footer__select">Rows per page:<div
class="v-input v-input--hide-details v-input--is-label-active v-input--is-dirty theme--light v-text-field v-text-field--is-booted v-select">
<div class="v-input__control">
<div role="button" aria-haspopup="listbox" aria-expanded="false" aria-owns="list-101"
class="v-input__slot">
<div class="v-select__slot">
<div class="v-select__selections">
<div class="v-select__selection v-select__selection--comma">10</div><input
aria-label="Rows per page:" id="input-101" readonly="readonly" type="text"
aria-readonly="false" autocomplete="off">
</div>
<div class="v-input__append-inner">
<div class="v-input__icon v-input__icon--append"><i aria-hidden="true"
class="v-icon notranslate material-icons theme--light">arrow_drop_down</i>
</div>
</div><input type="hidden" value="10">
</div>
<div class="v-menu">
<!---->
</div>
</div>
</div>
</div>
</div>
<div class="v-data-footer__pagination">1-2 of 2</div>
<div class="v-data-footer__icons-before"><button type="button" disabled="disabled"
class="v-btn v-btn--disabled v-btn--icon v-btn--round v-btn--text theme--light v-size--default"
aria-label="Previous page"><span class="v-btn__content"><i aria-hidden="true"
class="v-icon notranslate material-icons theme--light">chevron_left</i></span></button>
</div>
<div class="v-data-footer__icons-after"><button type="button" disabled="disabled"
class="v-btn v-btn--disabled v-btn--icon v-btn--round v-btn--text theme--light v-size--default"
aria-label="Next page"><span class="v-btn__content"><i aria-hidden="true"
class="v-icon notranslate material-icons theme--light">chevron_right</i></span></button>
</div>
</div>
</div>
</div>
I figured out the issue. The vue component was using 'scoped' styles which stops styling from applying to child components. I removed the scoped from <style scoped> and now it works as expected.

bootstrap table is not responsive

I have a table which fills data from database. Though i had use the bootstrap when i kept on decreasing the width of the browser, from one point onward the table is going outside the container. How can i make this responsive ? Following are the attached images
<table class="table table-responsive table-bordered">
<tr>
<th>Spare Id</th>
<th>Part Number</th>
<th>Quantity</th>
<th>Price</th>
<th>Warranty</th>
{{--<th>Description</th>--}}
<th>Spare Image</th>
<th>
<input type="text" class="form-control" id="search" placeholder="Search Spare">
</th>
</tr>
<tbody id="tableModel">
<?php
foreach($spares as $spare){
?>
<tr>
<td ><?php echo $spare->id;?></td>
<td ><?php echo $spare->partNumber;?></td>
<td ><?php echo $spare->quantity;?></td>
<td ><?php echo 'Rs.'. $spare->price;?></td>
<td ><?php echo $spare->warranty;?></td>
<td><?php echo '<img class="img-responsive" src="data:image/jpeg;base64,'.base64_encode( $spare->image ).'"/>';?></td>
<td>
<a class=" btn btn-success btn-sm" data-toggle="modal" data-target="#modalEdit" onclick="EditBrand('<?php echo $brand->brandName;?>','<?php echo $brand->id;?>')" >Edit </a>
<a onclick="DeleteBrand(<?php echo $brand->id;?>)" style="" class=" btn btn-danger btn-sm" >Delete </a>
</td>
</tr>
<?php }?>
</tbody>
</table>
If you use bootstrap. Wrap your table in a div with table-responsive class.
<div class="table-responsive">
<table class="table">
...
</table>
</div>
That should work if bootstrap is correctly integrated. Please show your code. Many more people would help you.
You can find this specific information here:
https://getbootstrap.com/docs/5.0/content/tables/#responsive-tables
I have worked a lot n this issue and found a good solution for this bootstrap table responsiveness issue. Just use the CSS below:
.table{
display: block !important;
overflow-x: auto !important;
width: 100% !important;
}
Add this line, that will solve your problem.
<div class='table-responsive'>
<div style="overflow-x:auto;">
Make sure you checked you have inserted enough data in table. Sometimes there is just not enough data to trigger 'table-responsive' property.

Shifting text using CSS

Using this code:
<div class="details">
<strong>Publisher:</strong>
<span class="red"><asp:Label ID="LabelPublisher" runat="server"></asp:Label></span>
</div>
<div class="details">
<strong>Author:</strong>
<span class="red"><asp:Label ID="LabelAuthor" runat="server"></asp:Label></span>
</div>
<div class="details">
<strong>Year:</strong>
<span class="red"><asp:Label ID="LabelYear" runat="server"></asp:Label></span>
</div>
...text on browser appears like this:
Publisher: publisher1
Author: author1
Year: 2014
Now using CSS I want to shift text like this on each label:
Publisher:---Publisher1
Author:-----Author1
Year:------ 2014
You can give fixed min width to strong tag
.details strong {
display: inline-block;
min-width: 100px;
}
DEMO
You should use a table for displaying text in that way.
Here is an example: http://jsfiddle.net/h8tshvty/
<table>
<tr class="details">
<td><strong>Publisher:</strong></td>
<td class="red">Publishername</td>
</tr>
<tr class="details">
<td><strong>Author:</strong></td>
<td class="red">Author name</td>
</tr>
<tr class="details">
<td><strong>Year:</strong></td>
<td class="red">Yearnumber</td>
</tr>
</table>

How to write CSS expression to click on "Select " i have tried with different x path its not working in IE any version

<div class="row-fluid">
<table class="s-table table table-bordered table-striped table-hover">
<thead class="p-table-head">
<tbody class="p-table-body">
<tr>
<td>
<td>
<td>
<td>
<td>
<td>
<td>
<td>
<td>
<td>
<div id="div_2_1_2_1_1_1_10_r9" class="Action_Group CoachView CoachView_show" data- eventid="" data-viewid="Action_Group1" data-config="config_div_2_1_2_1_1_1_10_r9" data-bindingtype="" data-binding="" data-type="com.ibm.bpm.coach.Snapshot_9e739df9_ccc7_4dfa_9b75_8233150ad5bc.Action_Group">
<div id="div_2_1_2_1_1_1_10_1_r9" class="ContentBox" data-view-managed="true" style="display: none;"> </div>
<div class="s-action-group clearfix">
<div class="l-nodeId" style=" display: none; "></div>
<div class="p-action-group">
<div id="div_2_1_2_1_1_1_10_1_1_r9" class="Action CoachView CoachView_show" data- eventid="boundaryEvent_10" data-viewid="Action3" data-config="config_div_2_1_2_1_1_1_10_1_1_r9" data-bindingtype="" data-binding="" data-type="com.ibm.bpm.coach.Snapshot_9e739df9_ccc7_4dfa_9b75_8233150ad5bc.Action" style="background-color: transparent;">
<button id="div_2_1_2_1_1_1_10_1_1_r9-lnk" type="button" style="display: none;">
<a class="p-action-link" href="#action" title="">
<i style="display: none;"></i>
<span style="background-color: transparent;">Select</span>
</a>
</div>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
I have tried with the following different x path expression its works fine in Firefox but in IE browser it is not working?.
//tbody[#class='p-table-body']/tr/td[10]/div/div/div/div/a/span
//table[#class='s-table table table-bordered table-striped table- hover']/tbody/tr[1]/td[10]/div/div/div[2]/div/a/span
//*[#id='div_2_1_2_1_1_1_10_1_1_r9']/a/span
Note : i have tried to execute scripts it is not fail but main issue it is not recognizing
select link of a customer.
Try
//*[#id='div_2_1_2_1_1_1_10_1_1_r9-lnk']/a/span
to click on select
Not sure if it can help, but try selecting just the 'a' element, instead. There's no need to select also the span element, as far as I can understand. E.g.:
By.cssSelector("#div_2_1_2_1_1_1_10_1_1_r9 a.p-action-link")
Also, a couple of recommendations.
Try to avoid xpath selectors, and write css selectors instead. See selenium-docs
While writing a selector, you should not be too strict. "/tr/td[10]/div/div/div/div" is considered bad practice.
See Writing reliable locators for Selenium and WebDriver tests
Try to identify the element by using the text identifier
driver.findElement(By.xpath("//a/span[text()='Select']")).click();

Selecteting element if previous TD with CSS

If have the following HTML (there could be more TDs), can I select ALL <div>s with style divE in all TDs before the one with id="current"?
I think i can do it with jQuery, but can this be done with pure CSS?
HTML
<table id="myTbl" cellpadding="0" cellspacing="0">
<tr>
<td>
<div class="red">asdasd</div>
<div class="divE"></div>
<div class="divE"></div>
content
</td>
<td id="current">
<div class="red">asdasd</div>
<div class="divE"></div>
<div class="divE"></div>
content
</td>
<td>
<div class="red">asdasd</div>
<div class="divE"></div>
<div class="divE"></div>
content
</td>
</tr>
</table>
There's no before selector, but what you can do is select all tds (that aren't #current), and then "reset" (or "undo") the styles on all the tds after #current.
td:not(#current) div.divE{
/* Styles for <td>s before "#current" */
}
td#current ~ td div.divE{ /* This means all "td div.divE" after "td#current" */
/* Reset/undo styles for all other <td>s */
}
DEMO: http://jsfiddle.net/MYhPP/2/

Resources