Styling a PrimeFaces panelGrid within a data table using CSS

I am struggling to add a background color to a panelgrid within a datatable when a hover event occurs. Despite writing the necessary code and CSS, nothing seems to work. Any suggestions on how to address this issue?

<p:dataTable id="movementsTable" var="mov" value="#{movementsBacking.movements}" selectionMode="single" selection="#{movementsBacking.selectedMovement}" rowKey="#{mov.id}"
                           styleClass="nopadding " rowStyleClass="roteiroTable" style="margin: 0;" emptyMessage="#{text['list.empty']}" > 

            <p:ajax event="rowSelect" update=":#{cc.clientId}:movementPanel" oncomplete="PF('movementPanelVar').show()"  listener="#{movementsBacking.onSelect}"/>

            <p:column headerText="#{text['tasksbacking.tabRot']}" sortBy="#{mov.dataSent}">
                <p:panelGrid id="panelGridSelect" rendered="#{mov.isTreated()}" styleClass="borderless">
                    <p:row>
                        <p:column>
                            <h:outputLabel value="#{text['tasksbacking.roteiro.num']}" style="margin-right:5px;"/>
                            <h:outputText id="num" value="#{mov.number}"/>
                        </p:column>
                        <p:column>
                            <h:outputLabel value="#{text['tasksbacking.roteiro.data']}" style="margin-right:5px;"/> 
                            <h:outputText value="#{mov.dataSent}">
                                <f:convertDateTime pattern="dd-MM-yyyy"/> 
                            </h:outputText>
                        </p:column>
                    </p:row> 
                    <p:row>
                        ...
                        (remaining content of the snippet)
                        ...

The accompanying CSS:

.roteiroTable, .roteiroTable th, .roteiroTable td {
    background-color: #F1F1F1 !important;
}

.nopadding, .nopadding th, .nopadding td {
    padding: 0 !important;
}

.borderless, .borderless tr, .borderless td {
    border: none !important;
}

Answer №1

It is recommended that you choose the tr element. See the sample code below for reference.

<style>
    .customRowStyle tr{
        background-color: blue !important;
    }
</style>
<h:form>
    <p:dataTable var="item" 
                 value="#{dtBasicView.items}" 
                 rowStyleClass="customRowStyle">
        <p:column headerText="ID">
            <p:panelGrid>
                <p:row>
                    <p:column>
                        <h:outputText value="Item ID: " />
                    </p:column>
                    <p:column>
                        <h:outputText value="#{item.id}" />
                    </p:column>
                </p:row>
            </p:panelGrid>
        </p:column>

        <p:column headerText="Description">
            <h:outputText value="#{item.description}" />
        </p:column>

        <p:column headerText="Category">
            <h:outputText value="#{item.category}" />
        </p:column>

        <p:column headerText="Price">
            <h:outputText value="#{item.price}" />
        </p:column>
    </p:dataTable>
</h:form>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Modify the class's height by utilizing props

Using Vue 3 and Bootstrap 5, I have a props named number which should receive integers from 1 to 10. My goal is to incorporate the number in my CSS scrollbar class, but so far it's not working as expected. There are no error messages, it just doesn&a ...

What is the best way to align the text in the center of my h1 header?

Can anyone assist me with centering the contents of my h1 tag? h1{ width: 100%; vertical-align: middle; color: rgb(5, 5, 5); font-size:25px; letter-spacing: 0px; top: 0; text-align: left; padding: 10; }h1:after { content:' '; display: ...

Reducing Bootstrap Navigation Bar with a scrolling logo

Is there a way to make the fixed navbar shrink 50% when it starts scrolling? I've only come across text navbars, but I'm looking for one with a logo. Any suggestions would be greatly helpful. You can access the css and html from that link. ...

Tips for displaying two dynamic variables that are interdependent

For instance: Controller: AllBooks[{ book1:{ hardcover{price:25.99},e-book{price:1.99} } }, book2:{ hardcover{price:60.00},e-book{price:2.99} }]; $scope.bookchoice = function(selectedBook) { $rootScope.choice = selectedBook;} $scope.booktype = functio ...

Generating a div element within another div element

I have been attempting to add a new div inside an existing one using append, after, etc., but so far I have not been successful. The structure of the code is as follows: <div class="row"> <div class="col-xs-12" id="element-container"> &l ...

Tips for adding animation to the div instead of the content

I have implemented a hover animation to animate the div, but unfortunately, when I added the animation to #i :hover {}, it ended up animating the words only. Moreover, the cursor transforms into a pointer solely when hovering over the words instead of the ...

Is there a way to ensure that the elements created by the select form are only generated once?

I have a JavaScript function that dynamically creates paragraph and input elements based on user selection in HTML. However, I am looking to optimize the code so that each element is only created once. Snippet of JavaScript code: function comFunction(sel ...

Setting up VideoJS Flash backup

Due to Firefox's restriction on using an .mp4 file in the <video> tag, I am required to utilize the Flash fallback option on my VideoJS player. When it comes to Chrome, Safari, and IE, I can customize my VideoJS player via JavaScript to perform ...

Tips for expanding a script that relocates a logo into a navigation consisting of several unordered lists

I recently implemented a jQuery script to center a logo within my main navigation bar only when the screen width is above 980 pixels. It was working perfectly fine with a single unordered list, but as soon as I added more unordered lists within the nav, it ...

Closing the space between vertical edges of table data cells

I'm currently in the process of translating my resume from MS Word to HTML and CSS for easier maintenance and sharing purposes. I really like the layout and style of my resume and want to maintain it. The design features a left column with bold titles ...

How should text inputs be positioned?

I'm not very experienced with forms, so I'm a bit confused about what's happening here. I'm attempting to position a text input inline with a button, but it doesn't seem to be working. You can view the code I'm using here: htt ...

I am experiencing an issue where my JavaScript code does not redirect users to the next page even

I'm experiencing an issue with this code where it opens another webpage while leaving the login screen active. I've tried multiple ways to redirect it, such as window.location.href and window.location.replace, but nothing seems to be working. Ide ...

Stop tooltips from appearing on hyperlinks in Internet Explorer

Is there a solution to disabling the pesky tooltips that appear in the bottom left corner of IE when hovering over links? Alternatively, is there a method to customize the text that appears instead of the default tooltip when hovering over a link (I attem ...

Enabling the upload of .sql files in a file input field

I'm working on a file input field that I want to restrict to only accept XML, SQL, and text files. Here's the code snippet I have implemented so far: <input type="file" name="Input_SQL" id="Input_SQL" value="" accept="text/plain,application/x ...

Unable to showcase array JSON values on HTML using ng-model

Utilizing ngTagInput for autocomplete textbox and successfully receiving suggestions. To display the values of data-ng-model (named "list") I am using: {{list}} and it is showing correctly. However, when selecting "list1", the display appears as: [{"lis ...

Creating a curved edge for a shape in React Native can add a stylish and

Issue Description I am working on an app and struggling with styling the bottom navigation bar. It's more complex than what I've done before, especially the curved top edge of the white section and the area between the blue/green circle and the ...

Utilize Angular to initiate the transmission of attribute values upon a click event

My question may be simple, but I've been struggling to find an answer. How can I send attributes or item property bindings of an item through a click event in the best way? For example: <item class="item" [attr.data-itemid]="item.id ...

Struggling to get .parent().toggleClass to function properly

Check out this fiddle: https://jsfiddle.net/qxnk05ua/2/ I'm trying to get the background color to change when I click the button, but it's not working. Can you help me figure out why? This is the Javascript code I'm using: $(document).rea ...

Personalize or delete the spacing within an ion row

Currently, I am delving into the world of Ionic app development. Although I have grasped the concept of the Grid layout, I find myself hitting a roadblock when it comes to adjusting or removing spaces between rows 2 and 3 in my app interface, as illustrate ...

What is the process for creating a personalized <a> tag using CSS?

On my website, I am looking to differentiate between two types of <a> tags - one for inline links and the other for standalone links. This means that I want these two variations of <a> tags to have distinct colors and styles. For inline links, ...