![](/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.