如何获得Primefaces数据表当前页面上的总记录(通过YUI分页器)

How to get total record on the current page(via YUI paginator) of Primefaces datatable

本文关键字:通过 记录 YUI 分页 Primefaces 何获得 数据表 当前页      更新时间:2023-09-26

我使用下面的代码:

 <script type="text/javascript">
                    function test(){
                        var arr = product.getPaginator().getPageRecords(1);
                    }
                </script>
                <p:dataTable  selection="true" widgetVar="product" id="cars" editMode="cell" editable="true" 
                              var="carr" value="#{tabview.l1}" paginator="true" rows="3">  
                    <p:column headerText="Model">  
                        <h:outputText value="#{carr.model}" />
                    </p:column>  
                    <p:column headerText="MANUFAC" style="width:20%">  
                        <h:outputText value="#{carr.manufacturer}" />
                    </p:column>  
                </p:dataTable>
                <p:commandButton oncomplete="test();" value="Test"/>

当我运行该代码时,我有错误:Uncaught TypeError: Object [object Object] has no method 'getPageRecords'

在YUI指令中,该方法已经存在:http://developer.yahoo.com/yui/paginator/#api

感谢大家的关注,Primefaces不使用YUI,所以我必须通过:

$(PrimeFaces.escapeClientId('form:cars')).find('tr').length
function datatablelength(){
    var dt = document.getElementById('myDatatable_data');
    alert(dt.rows.length);
}

其中'myDatatable'是我的p的ID:datatable