Search code examples
javascriptprimefacesyui

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'

In YUI instruction, that method already existed: http://developer.yahoo.com/yui/paginator/#api

Thank for your attention !


Solution

  • Thank for all attention, Primefaces doesn't use YUI, so i have to get by:

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