简体   繁体   English

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

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

I use code below: 我在下面使用代码:

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

When i run that code, i have error: Uncaught TypeError: Object [object Object] has no method 'getPageRecords' 当我运行该代码时,出现错误: Uncaught TypeError: Object [object Object] has no method 'getPageRecords'

In YUI instruction, that method already existed: http://developer.yahoo.com/yui/paginator/#api 在YUI指令中,该方法已经存在: http : //developer.yahoo.com/yui/paginator/#api

Thank for your attention ! 感谢您的关注 !

感谢所有关注,Primefaces不使用YUI,所以我必须解决:

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

where 'myDatatable' is the ID of my p:datatable 其中“ myDatatable”是我的p:datatable的ID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM