0

I have a Pageblock where I am listing all contacts of an Account and I got a picklist status - Active & Inactive.

After picklist values are changed, we can save the list of records but there is no page redirect.

We got another action being done in another button which would disable the save button. And if a user once again changes the picklist values we should enable the Save button which is in the same Pageblock.

<apex:commandbutton action="{!Save method}" disable="{!booleanforsave}"/>
<apex:inputfield value="{!picklistfield}"> 

There is no rerender attribute in inputfield so I am using actionsupport

<apex: actionsupport event="Onchange" rerender="form" action="{!enablesavebutton}"/>

But none of them are working. Please help me out

  • Please align the code, It wouldn't be visible until you do so. – C. Praveenkumar Dec 2 '16 at 10:51
  • The On change should be one word event="onchange". Check if this is a issue. – Saroj Bera Dec 2 '16 at 11:16
  • Yes, I wrote it as single word. It's a typo here – SFDev Dec 5 '16 at 7:27
2

IF you want to call a method on change of a field in a list, then I would suggest go for a javascript event handlers. Else there will be many calls to your controller every time there is a change of that field in that list.

As per your code:

<apex:inputfield value="{!picklistfield}"> 
<apex: actionsupport event="On change" rerender="form" action="{!enablesavebutton}"/>
</apex:inputfield>

Change it to

<apex:inputfield value="{!picklistfield}" oncomplete="DisableSaveButton(passyourbuttonid);"/> 

<script>    
    function DisableButton(button) {
        button.disabled = 'true';
        button.className = 'btnDisabled';
    }
</script>

Reference: http://resource-centre.net/free-javascript-tutorials/event-handlers-javascript/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.