How to conditionally style a row in a rich:dataTable

后端 未结 7 1458
攒了一身酷
攒了一身酷 2021-02-07 02:12

How can I change the style of a particular row based on a condition? I can use JSF EL in rich:column style class attribute, but I have to write for each column. I want to change

7条回答
  •  我在风中等你
    2021-02-07 02:35

    This is my code, there is a checkbox on each row, if a checkbox is selected, the row is highlighted:

    
    
            
              
                
              
              
            
    
            
              
                
              
              
            
    
            
              
                
              
              
            
    
            
              
                
              
              
            
    
            
              
                
              
              
            
    
            
              
                
              
              
            
    
            
              
                
              
              
            
    
            
              
                
              
              
            
    
            
              
                
              
              
            
    
            
              
                
              
              
                 
              
            
          
    

    In my backing bean:

    public String getRowcolor() {
        if (selected) // selected is a variable whose value is from the checkBox  
            return "row-highlight-color"; // css id
        else
            return "row-white-color"; // css id
        }
    

提交回复
热议问题