Add new record in primefaces datatable and setfocus
<p>I want to add a new record in primefaces datatable on clck action. Also i must open the new row in edit mode.
I am able to achieve this by using below code.</p>

<p>Html:</p>

<pre><code>&lt;p:commandLink
                            actionListener="#{myBean.addRecord}"
                             update="myDatatable" 
                            oncomplete="jQuery('#myForm\\:myDatatable .ui-datatable-data &gt; tr').first().find('span.ui-icon-pencil').click();
                            "&gt;
&lt;p:graphicImage value="/resources/images/add.jpg"  width="25"/&gt;
&lt;/p:commandLink&gt;
</code></pre>

<p>Managed Bean:</p>

<pre><code>public void addRecord(){

        if(getMyList() != null) {
            getMyList().add(0, new SisTestReportDetail());
        }
    }
</code></pre>

<p>I tried doing as shown below,but not working.</p>

<pre><code>jQuery('#myForm\\:myDatatable .ui-datatable-data &gt;` tr').first().focus();
</code></pre>