rowEditor and cellEditor with footer inputs to add

Posted: August 28, 2012 in web
        <h:form>
            <p:dataTable value="#{bean.cards}" var="card" editable="true">
                <p:ajax event="rowEdit" listener="#{bean.onEdit}" />
                <p:column headerText="Label">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{card.label}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{card.label}" />
                        </f:facet>
                    </p:cellEditor>
                    <f:facet name="footer">
                        <p:inputText styleClass="cardLabel" value="#{card.label}" />
                    </f:facet>
                </p:column>
                <p:column headerText="Value">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{card.value}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputTextarea value="#{card.value}" />
                        </f:facet>
                    </p:cellEditor>
                    <f:facet name="footer">
                        <p:inputText styleClass="cardValue" value="#{card.value}" />
                    </f:facet>
                </p:column>
                <p:column headerText="Options">
                    <p:commandLink process="@this" onclick="disable();">
                        <p:rowEditor>
                            <p:ajaxStatus oncomplete="enable();" />
                        </p:rowEditor>
                    </p:commandLink>
                    <f:facet name="footer">
                        <p:commandButton action="#{bean.onAdd()}" value="Add" />
                    </f:facet>
                </p:column>
            </p:dataTable>
        </h:form>
<script>
function disable(){
     $('.critValue').attr('disabled','disabled');
     $('.critLabel').attr('disabled','disabled');   
}
function enable(){
    $('.critValue').removeAttr('disabled');
    $('.critLabel').removeAttr('disabled');   
}
</script>
Advertisements
Comments
  1. csaez says:

    I need that when ajax event=”rowEdit” update a button from footer on datatable

  2. anonimo says:

    With commandLink the rowEditor keep in pencil icon don’t change to check and cancel icon 😦

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s