[Ajax4JSF] rich:dataTable 栏位显示问题

无双Rama 2009-09-10
要求实现dateTable的栏位值如果是数字向右对齐,其它默认不管

解决一:给每个栏位写<rich:column style="text-align:right">

可是我觉得这样太繁琐了,每张表有4、5个要这样处理的栏位,而且有几十张表。。。

有没有更好的办法呢?比如修改richfaces自带的css、xcss ,或者写脚本判断?

或者用facelets写一个自定义标签?还是有其它更好的办法?

有没有最简洁有效的办法呢??

我该如何做,请各位来帮我想想办法
无双Rama 2009-09-10
怎么沒人來说说自己的看法呢?
coolstone 2009-10-10
用css控制,styleClass="Grid" headerClass="Header"  columnClasses="GridColumn" rowClasses="OddRow, EvenRow"

<rich:dataTable width="100%" id="serviceList" var="_item"
			value="#{serviceList.resultList}" rowKeyVar="rowKey"
			rendered="#{not empty serviceList.resultList}" styleClass="Grid"
			headerClass="Header" columnClasses="GridColumn"
			rowClasses="OddRow, EvenRow">
......
</rich:dataTable>

生成的html
<table class="dr-table rich-table Grid" id="list:exchangeNodeList" border="0" cellpadding="0" cellspacing="0" width="100%">
	<colgroup span="6"></colgroup>
	<thead class="dr-table-thead">
		<tr class="dr-table-subheader rich-table-subheader Header">
			<th class="dr-table-subheadercell rich-table-subheadercell Header " scope="col" id="list:exchangeNodeList:j_id110header">
									&#35814;&#24773</th>
			<th class="dr-table-subheadercell rich-table-subheadercell Header " scope="col">&#33410;&#28857;&#21517;&#31216;</th>
			<th class="dr-table-subheadercell rich-table-subheadercell Header " scope="col">&#25340;&#38899;&#31616;&#31216;</th>
			<th class="dr-table-subheadercell rich-table-subheadercell Header " scope="col">&#25152;&#23646;&#25104;&#21592;&#21333;&#20301;</th>
			<th class="dr-table-subheadercell rich-table-subheadercell Header " scope="col"> IP&#22320;&#22336;</th>
			<th class="dr-table-subheadercell rich-table-subheadercell Header " scope="col">&#33410;&#28857;&#29366;&#24577;</th>
		</tr>
	</thead>
	<tbody id="list:exchangeNodeList:tb">
		<tr class="dr-table-row rich-table-row dr-table-firstrow rich-table-firstrow OddRow">
			<td class="dr-table-cell rich-table-cell GridColumn richColumn" id="list:exchangeNodeList:0:j_id110">
				<img src="/framework/images/framework/tb_see_left.gif" alt="" style="border:0px;" />
			</td>
			<td id="list:exchangeNodeList:0:j_id116" class="dr-table-cell rich-table-cell GridColumn">&#24066;&#24037;&#21830;&#23616;</td>
			<td id="list:exchangeNodeList:0:j_id123" class="dr-table-cell rich-table-cell GridColumn">GZ_GONGSHANG</td>
			<td id="list:exchangeNodeList:0:j_id130" class="dr-table-cell rich-table-cell GridColumn"> &#24066;&#24037;&#21830;&#23616;</td>
			<td id="list:exchangeNodeList:0:j_id133" class="dr-table-cell rich-table-cell GridColumn">172.16.8.163</td>
			<td id="list:exchangeNodeList:0:j_id136" class="dr-table-cell rich-table-cell GridColumn">&#27491;&#24120;</td>
		</tr>
	</tbody>
</table> 


可以看出生成的td 有三个css,"dr-table-cell rich-table-cell GridColumn",前两个为richfaces自带的,最后一个是我们加上的,既可以改写richfaces自带的,也可以重新定义新样式GridColumn:

.Grid .GridColumn {
         text-align: right;
	font-size: 14px;
	BORDER-BOTTOM: #c0c0c0 0px solid;
	
}
terryzhou 2009-10-12
facelets是最好的解决方案,以后有变化,修改一处即可,CSS的话还是要改N个页面。
Global site tag (gtag.js) - Google Analytics