adjust the rows dynamically in paginator of primefaces datatable -


i using primefaces datatable paginator. have fixed no of rows 15. correctly matches system resolution. users using monitors different(bigger) resolutions. no of rows in case less , space displayed @ bottom. way can increase these rows dynamically based on screen resolution. below code using.

<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"> 

any suggestion on this.

1.define 2 jsf inputhidden fields screenheight, , screenwidth in xhtml files
2.calculate computedheight , computedwidth using javascript when page loads , store hidden fields.
3.automatically value binded managedbean varaibles.
4.write method return no of rows based on screenheight , screen width
5.call method via expression language in jsf datatable rows attribute

sample xhtml file follows

 <h:head>       <script type="text/javascript">  	       function setresolution(){   	     		//calculated computedheight , computedwidth 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>

sample managed bean reference

@managedbean  public class managedbean implements serilizable{    private float screenheight;  private float screenwidth;  //gets , setters    private int calculatedrows(){  //your business logic return no of rows based on   //screenheight , screenwidth(resolution)  }      }


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -