在 primefaces 数据表的分页器中动态调整行
adjust the rows dynamically in paginator of primefaces datatable
我正在使用 primefaces 数据表分页器。我已将行数固定为 15。这与我的系统分辨率完全匹配。但是用户正在使用具有不同(更大)分辨率的显示器。这种情况下的行数会更少,space 将显示在底部。
我可以根据屏幕分辨率动态增加这些行的任何方式。
下面是我正在使用的代码。
<p:dataTable var="order" value="#{orderdetails.orderDetailsList}" scrollable="true" styleClass="ui-dynamic-height"
sortMode="multiple" emptyMessage="" frozenColumns="1" resizableColumns="true" widgetVar="orderstatustable"
liveResize="true" paginator="true" rows="15" paginatorPosition="top" paginatorAlwaysVisible="false">
对此有何建议。
1.Define xhtml 文件中的两个 JSF inputHidden 字段表示 screenHeight 和 screenWidth
2.Calculate computedHeight 和 computedWidth 在页面加载时使用 javascript 并将其存储到隐藏字段中。
3.Automatically 该值将绑定到 managedbean 变量。
4.Write 一种方法 return 基于屏幕高度和屏幕宽度的行数
5.Call 该方法通过 JSF 数据表行属性中的表达式语言
示例 XHTML 文件如下
<h:head>
<script type="text/javascript">
function setResolution(){
//Calculated the computedHeight and computedWidth from javascript
document.getElementById('myForm:screenHeight').value = computedHeight;
document.getElementById('myForm:screenWidth') .value=computedWidth;
}
</script>
</h:head>
<h:body onload="setResolution();">
<h:form id="myForm">
<h:inputHidden id="screenHeight" value="#{managedBean.screenHeight}" />
<h:inputHidden id="screenWidth" value="#{managedBean.screenWidth}" />
// call rows="#{managedBean.calculatedRows}"
<p:dataTable var="order" value="#{orderdetails.orderDetailsList}" scrollable="true" styleClass="ui-dynamic-height" sortMode="multiple" emptyMessage="" frozenColumns="1" resizableColumns="true" widgetVar="orderstatustable" liveResize="true" paginator="true" rows="#{managedBean.calculatedRows}" paginatorPosition="top" paginatorAlwaysVisible="false">
</p:dataTable>
</h:form>
</h:body>
示例托管 Bean 供您参考
@ManagedBean
public class ManagedBean implements serilizable{
private float screenHeight;
private float screenWidth;
//gets and setters
private int calculatedRows(){
//Your business logic to return no of rows based on
//screenHeight and screenWidth(resolution)
}
}
我正在使用 primefaces 数据表分页器。我已将行数固定为 15。这与我的系统分辨率完全匹配。但是用户正在使用具有不同(更大)分辨率的显示器。这种情况下的行数会更少,space 将显示在底部。 我可以根据屏幕分辨率动态增加这些行的任何方式。 下面是我正在使用的代码。
<p:dataTable var="order" value="#{orderdetails.orderDetailsList}" scrollable="true" styleClass="ui-dynamic-height"
sortMode="multiple" emptyMessage="" frozenColumns="1" resizableColumns="true" widgetVar="orderstatustable"
liveResize="true" paginator="true" rows="15" paginatorPosition="top" paginatorAlwaysVisible="false">
对此有何建议。
1.Define xhtml 文件中的两个 JSF inputHidden 字段表示 screenHeight 和 screenWidth
2.Calculate computedHeight 和 computedWidth 在页面加载时使用 javascript 并将其存储到隐藏字段中。
3.Automatically 该值将绑定到 managedbean 变量。
4.Write 一种方法 return 基于屏幕高度和屏幕宽度的行数
5.Call 该方法通过 JSF 数据表行属性中的表达式语言
示例 XHTML 文件如下
<h:head>
<script type="text/javascript">
function setResolution(){
//Calculated the computedHeight and computedWidth from javascript
document.getElementById('myForm:screenHeight').value = computedHeight;
document.getElementById('myForm:screenWidth') .value=computedWidth;
}
</script>
</h:head>
<h:body onload="setResolution();">
<h:form id="myForm">
<h:inputHidden id="screenHeight" value="#{managedBean.screenHeight}" />
<h:inputHidden id="screenWidth" value="#{managedBean.screenWidth}" />
// call rows="#{managedBean.calculatedRows}"
<p:dataTable var="order" value="#{orderdetails.orderDetailsList}" scrollable="true" styleClass="ui-dynamic-height" sortMode="multiple" emptyMessage="" frozenColumns="1" resizableColumns="true" widgetVar="orderstatustable" liveResize="true" paginator="true" rows="#{managedBean.calculatedRows}" paginatorPosition="top" paginatorAlwaysVisible="false">
</p:dataTable>
</h:form>
</h:body>
示例托管 Bean 供您参考
@ManagedBean
public class ManagedBean implements serilizable{
private float screenHeight;
private float screenWidth;
//gets and setters
private int calculatedRows(){
//Your business logic to return no of rows based on
//screenHeight and screenWidth(resolution)
}
}