如何在Primefaces数据表的当前页面(通过YUI paginator)获取总记录

时间:2013-04-22 07:48:21

标签: javascript primefaces yui

我使用以下代码:

 <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

感谢您的关注!

2 个答案:

答案 0 :(得分:0)

感谢所有人的关注,Primefaces并没有使用YUI,所以我必须得到:

$(PrimeFaces.escapeClientId('form:cars')).find('tr').length

答案 1 :(得分:0)

function datatablelength(){
    var dt = document.getElementById('myDatatable_data');
    alert(dt.rows.length);
}

其中'myDatatable'是我的p:datatable

的ID
相关问题