![](/img/trans.png)
[英]Setting Column Width as Percent in RichFaces 4.x ExtendedDataTable
[英]Show/hide column in rich:extendedDataTable (RichFaces 4.x)
RichFaces針對rich:extendedDataTable
的顯示/隱藏列功能在版本4.x中不再可用。 有什么想法如何以其他方式實現它嗎?
我嘗試使用JavaScript和document.getElementById()
函數並設置元素的style.display
屬性來實現此目的,但是由於id rich:table
中的所有元素都是動態生成的,因此很難通過id來查找元素。
任何幫助和提示將不勝感激。
在Richfaces 4.x ExtendedDataTable中,您可以使用CSS樣式同時控制該列的標題和正文。 每列的CSS樣式均以前綴“ .rf-edt-c-”和列ID創建。 如果您的ID為“ column1”的列,則CSS樣式將為“ .rf-edt-c-column1”。 以下是在Java Script中隱藏/顯示具有列ID的列的示例。
<script type="text/javascript">
//<![CDATA[
function hideColumn(columnId)
{
var styleSheets = document.styleSheets;
for(var i=0;i<styleSheets.length;i++)
{
var rules = null;
// IE and Chrome
if(styleSheets[i].rules != null)
{
rules = styleSheets[i].rules;
}
// Firefox
else if(styleSheets[i].cssRules != null)
{
rules = styleSheets[i].cssRules;
}
for(var j=0;j<rules.length;j++)
{
// Find the css style of that column
if(rules[j].selectorText==".rf-edt-c-" + columnId)
{
rules[j].style.display = "none";
}
}
}
}
function showColumn(columnId)
{
var styleSheets = document.styleSheets;
for(var i=0;i<styleSheets.length;i++)
{
var rules = null;
// IE and Chrome
if(styleSheets[i].rules != null)
{
rules = styleSheets[i].rules;
}
// Firefox
else if(styleSheets[i].cssRules != null)
{
rules = styleSheets[i].cssRules;
}
for(var j=0;j<rules.length;j++)
{
// Find the css style of that column
if(rules[j].selectorText==".rf-edt-c-" + columnId)
{
rules[j].style.display = "";
}
}
}
}
//]]>
</script>
只需將屬性visible="false"
放在the rich:column
標記中,如下所示:
<rich:column id="name" label="Name" sortable="true" sortBy="#{edt.name}" visible="false">
RichFaces版本錯誤,抱歉。
我將此添加到rich:column
屬性中:
width="#{myBean.testDisplay('toDisplay')?'':'0px;border:none;'}"
它比使用rendered
更好,因為rendered
錯誤會重新排列列。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.