function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sascha DeinertSascha Deinert 

onclick row color and actionsupport

Hi,

If I click in the column, the column is green, but the action is not working anymore. Could you help me to solve the problem.
If I click another account, the colum is also green, it is possible to reset the column before to blank?

Thanks,
Sascha
 
<apex:pageblock id="pbAcc">
<apex:outputpanel style="overflow:scroll;height:200px;" layout="block">
    <apex:pageblocktable value="{!AccList}" var="Acc">
        <apex:column headervalue="Name" onclick="this.style.backgroundColor='green'">
     <apex:outputField value="{!Acc.Name}"/>
            <apex:actionSupport event="onclick" action="{!fetchOpps}" rerender="pbOpp">
                <apex:param assignTo="{!SelectedAccountId}" value="{!Acc.Id}" name="SelectedAccountId"/>
            </apex:actionSupport>
        </apex:column>        
        <apex:column headervalue="Street">
            <apex:outputfield value="{!Acc.BillingStreet}" />
        </apex:column>
        <apex:column headervalue="City">
            <apex:outputfield value="{!Acc.BillingCity}" />
        </apex:column>
    </apex:pageblocktable>   
</apex:outputpanel>
</apex:pageblock>

 
Best Answer chosen by Sascha Deinert
Darshan Shah2Darshan Shah2
Hello Sascha Deinert,

If nothing works for you then try below code: (just added small piece of javescript.. Removed onclick from apex:column.. added onsubmit on actionsupport)

<script>
        function changeColor(elem){
            elem.style.backgroundColor = 'Green';
        }
    </script>
    <apex:form >
        <apex:pageblock id="pbAcc">
            <apex:outputpanel style="overflow:scroll;height:200px;" layout="block">
                <apex:pageblocktable value="{!AccList}" var="Acc">
                   <apex:column headervalue="Name">
                     <apex:outputField value="{!Acc.Name}"/>
                        <apex:actionSupport event="onclick" action="{!fetchOpps}" rerender="pbOpp" onsubmit="changeColor(this);">
                            <apex:param assignTo="{!SelectedAccountId}" value="{!Acc.Id}" name="SelectedAccountId"/>
                        </apex:actionSupport>
                    </apex:column>       
                        <apex:column headervalue="Street">    
                        <apex:outputfield value="{!Acc.BillingStreet}" />
                    </apex:column>
                    <apex:column headervalue="City">
                        <apex:outputfield value="{!Acc.BillingCity}" />
                    </apex:column>
                </apex:pageblocktable> 
            </apex:outputpanel>
        </apex:pageblock>
    </apex:form>


Warm Regards,
Darshan Shah