Expand collapse of table rows in Datatable JSF

前端 未结 3 1221
广开言路
广开言路 2020-12-18 14:13

I have been trying to achieve this functionality of expand/collapse of table rows using core JSF and also I have to preserve the sorting. Is there a way in core JSF where I

3条回答
  •  暖寄归人
    2020-12-18 14:50

    If you insist in using reference implementation only, then you can't go around using a nested h:dataTable and/or h:panelGroup and a good shot of CSS to get it aligned nicely. You can then use JavaScript the smart way to show/hide row details.

    Here's a basic kickoff example:

    
        
            
                
                
                
            
            
        
    
    

    The toggleDetails() function can look like (note that it takes JSF generated client ID into account):

    function toggleDetails(image) {
        var detailsId = image.id.substring(0, image.id.lastIndexOf(':')) + ':details';
        var details = document.getElementById(detailsId);
        if (details.style.display == 'none') {
            details.style.display = 'block';
            image.src = 'collapse.gif';
        } else {
            details.style.display = 'none';
            image.src = 'expand.gif';
        }
    }
    

提交回复
热议问题