Search code examples
jsfjsf-2primefacesdatatable

p:datatable rows by default editable


so i have p:commpandButton which loads p:datatable on ajax see picture One. I want p:datatable in editable mode by default (when it loads) see picture two

picture One: enter image description here

picture Two: enter image description here

here is p:datatable :

<ui:composition template="/template/mastertemplate.xhtml">
  <ui:define name="content">
    <h:form styleClass="form" prependId="false">
      <p:panel id="analysisTheBudgetPenel" header="Analysis The Budget">
        <p:tabView id="scenarioTabViewId" style="width:850px">
           <p:tab title="Scenario One" id="scen">
              <h:selectBooleanCheckbox id="isApprovedBooleanId_checkBox" value="#{budgetAnalysisAction.budgetScenarioHescoProposalBean.abc}" />
              <p:scrollPanel style="width:800px; height:auto;">
              <p:dataTable id="budgetAnalysisDataTableId" rowIndexVar="index" editable="true" resizableColumns="true" value="#{budgetAnalysisAction.budgetScenarioHescoProposalBean.budgetScenarioHescoProposalListBean}" var="budgetScenarioHescoProposalList">
                 <p:ajax event="rowEdit" process="#{scenarioTabViewId:isApprovedBooleanId_checkBox}" listener="#{budgetAnalysisAction.testAjax}" />
// some columns
// closing tags of above

Solution

  • The body tag has onload event that trigger event when page is loaded, so you can trigger click event to pen icon by:

    <body onload="$('.ui-icon.ui-icon-pencil').click();">