1

My Visualforce page has a table displaying details from a controller list. The table has Inline Edit options which work on a Save button. I would like to check a checkbox for the row changed whenever a user makes an inline edit change in order to avoid having to go through every row. I can catch the change event, but don't know how to set the checkbox.

j$(".mc").change(function(e){
    var r = confirm("Are you sure you want to edit these activities?");                
    // here's where I need to set the checkbox for this row - how??
});

My table is as below:

<apex:pageBlock title="Call Cycle Events" mode="inlineEdit">
<apex:actionFunction name="rerenderDetail" rerender="detail"/>

        <apex:pageblockTable styleClass="cc_row" width="100%" rowClasses="odd,even" value="{!CCAModel}" var="cca">
            <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" 
                                    changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
            <apex:column id="sel" styleclass="cc_col3" headerValue="Sel">
                <apex:inputCheckbox styleClass="chkSel" value="{!cca.CallCycleActivity.Sel__c}"/>
            </apex:column>
            <apex:column styleclass="mc" headerValue="Frequency">
                <apex:outputField styleClass="lineId" id="ccaFre" value="{!cca.CallCycleActivity.Main_Contact__r.CallCycleFrequency__c}"/>
            </apex:column>
            <apex:column styleclass="mc" headerValue="Confirm">
                <apex:outputField styleClass="lineId" id="ccaConf" value="{!cca.CallCycleActivity.Main_Contact__r.ConfirmAppointment__c}"/>
            </apex:column>
            <apex:column styleclass="mc" headerValue="Method">
                <apex:outputField styleClass="lineId" id="ccaMeth" value="{!cca.CallCycleActivity.Main_Contact__r.PreferredContactMethod__c}"/>
            </apex:column>

        </apex:pageblockTable>

1 Answer 1

2

You can do it in the below way :

j$(".mc").change(function(e){
    var r = confirm("Are you sure you want to edit these activities?");                
    $(this).parent('.cc_row').find('.chkSel').prop('checked',true);
});

With a new edit suggested from @irene

j$(this).closest('tr').find('td[id$="sel"] input[id$="selchk"]').prop('checked', true); 

Hope this will help you :)

2
  • Thank you so much for this! It didn't work exactly as you said, but with a tweak it did. What I had to do was change it to what's here - if you edit your answer to this I can mark it as the answer :) : j$(this).closest('tr').find('td[id$="sel"] input[id$="selchk"]').prop('checked', true);
    – Irene
    Commented Jan 24, 2016 at 20:03
  • Edited my answer :) Commented Jan 25, 2016 at 0:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .