width of column in rich:datatable
I am using JSF 1.2, in one of my web page i am using开发者_如何转开发 . I want to set column's width.
<rich:dataTable id="dt" border="1" cellpadding="2" cellspacing="0" width="100%">
<rich:column filterBy="" filterEvent="onkeyup" sortBy="">
<f:facet name="header1">
<h:outputText value="header1" />
</f:facet>
<h:outputText value="myValue1"></h:outputText>
</rich:column>
<rich:column filterBy="" filterEvent="onkeyup" sortBy="">
<f:facet name="header2">
<h:outputText value="header2" />
</f:facet>
<h:outputText value="myValue2"></h:outputText>
</rich:column>
</rich:dataTable>
In one of rich:column i need to set width for column, for this i tried like
1) width="100px"
2) headerClass="myWidth"
and declared myWidth
in css file,
.myWidth {width:100px;}
(as mentioned in
column width in rich:datatable)
but both did not work.
can anyone help me to set column width.
Use columnClasses attribute of rich:dataTable and give a class or same class for each column.
<rich:dataTable columnClasses="col1Class,col2Class" ...
If you want to set width of selected columns then another option that rich:dataTable provides is you can do something like this:
<rich:dataTable id="dt" border="1" cellpadding="2" cellspacing="0" width="100%">
<rich:column filterBy="" filterEvent="onkeyup" sortBy="" styleClass="column1">
<f:facet name="header1">
<h:outputText value="header1" />
</f:facet>
<h:outputText value="myValue1"></h:outputText>
</rich:column>
<rich:column filterBy="" filterEvent="onkeyup" sortBy="" styleClass="column2">
<f:facet name="header2">
<h:outputText value="header2" />
</f:facet>
<h:outputText value="myValue2"></h:outputText>
</rich:column>
</rich:dataTable>
now you can easily define not just the width but any CSS property that you want using CSS class selector eg;
.column1{
width:30%;
}
精彩评论