• thomas_s
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

Hi,

 

I have an account controller extension with a save function:

 

public void save()
{
baseCtrl.save();
update acct.Contacts;
}

 

a corresponding actionFunction

 

<apex:actionFunction name="save" action="{!save}" rerender="table"/>

 and a pageBlockTable like this:

 

<apex:pageBlockTable value="{!account.Contacts}" var="con">
   <apex:column value="{!con.Name}"/>
   <apex:column value="{!con.MailingStreet}"/>
   <apex:column value="{!con.MailingCity}"/>
   <apex:column value="{!con.Phone}"/>
   <apex:column value="{!con.Visit_planned__c}"/>
   <apex:column headerValue="{!$ObjectType.contact.fields.Visit_planned__c.label}">
       <apex:inputCheckbox value="{!con.Visit_planned__c}" onclick="rerenderMap(this, '{!con.Id}')">
           <apex:actionSupport event="onchange" rerender="table"/>
       </apex:inputCheckbox>
   </apex:column>
</apex:pageBlockTable>

 

The JS rerenderMap(cb, id) function renders the contacts in a map and finally calls save() to update the database with the new checkbox value.

 

I uncheck a checkbox, the (for debug purposes shown) Visit_planned column is updated and the pushpin in the map is removed.

But when the save function is called, the db value of checked is written again and the table is rerendered with a checkmark again!

 

How can I update the db with the correct value?

 

Thanks,

Thomas

 

Hi,

 

I'd like to call a script function with the checkbox and the ID of the current record as parameters in a pageBlockTable in an inputCheckBox's onchange event.

 

If I use 'normal' parameters, my function is getting called, but if I fill in '{!con.Id}' as second parameter, a SUBMIT call is generated and my function is not called.

 

Next thing I'd like to know is how I can write back the changed checkbox value to the db. I guees I have to write a supporting save() function in my controller extension.

 

Can someone help me?

 

Here's an excerpt from my code:

 

<script>
function rerenderMap(cb, id)
{
// ... do something with cb.checked on record with id
}
</script>

<apex:pageBlock title="Kontakte" id="table">
  <apex:form >
     <apex:pageBlockTable value="{!account.Contacts}" var="con">
       <apex:column value="{!con.Name}"/>
       <apex:column value="{!con.MailingStreet}"/>
       <apex:column value="{!con.MailingCity}"/>
       <apex:column value="{!con.Phone}"/>
       <apex:column headerValue="{!$ObjectType.contact.fields.Visit_planned__c.label}">
         <apex:inputCheckbox value="{!con.Visit_planned__c}" onchange="rerenderMap(this, '{!con.Id}')">
           <apex:actionSupport event="onchange" rerender="table"/>
         </apex:inputCheckbox>
       </apex:column>
    </apex:pageBlockTable>
  </apex:form>
</apex:pageBlock>

 

Thanks,

 

Thomas

Hi,

 

I have an account controller extension with a save function:

 

public void save()
{
baseCtrl.save();
update acct.Contacts;
}

 

a corresponding actionFunction

 

<apex:actionFunction name="save" action="{!save}" rerender="table"/>

 and a pageBlockTable like this:

 

<apex:pageBlockTable value="{!account.Contacts}" var="con">
   <apex:column value="{!con.Name}"/>
   <apex:column value="{!con.MailingStreet}"/>
   <apex:column value="{!con.MailingCity}"/>
   <apex:column value="{!con.Phone}"/>
   <apex:column value="{!con.Visit_planned__c}"/>
   <apex:column headerValue="{!$ObjectType.contact.fields.Visit_planned__c.label}">
       <apex:inputCheckbox value="{!con.Visit_planned__c}" onclick="rerenderMap(this, '{!con.Id}')">
           <apex:actionSupport event="onchange" rerender="table"/>
       </apex:inputCheckbox>
   </apex:column>
</apex:pageBlockTable>

 

The JS rerenderMap(cb, id) function renders the contacts in a map and finally calls save() to update the database with the new checkbox value.

 

I uncheck a checkbox, the (for debug purposes shown) Visit_planned column is updated and the pushpin in the map is removed.

But when the save function is called, the db value of checked is written again and the table is rerendered with a checkmark again!

 

How can I update the db with the correct value?

 

Thanks,

Thomas

 

Hi,

 

I'd like to call a script function with the checkbox and the ID of the current record as parameters in a pageBlockTable in an inputCheckBox's onchange event.

 

If I use 'normal' parameters, my function is getting called, but if I fill in '{!con.Id}' as second parameter, a SUBMIT call is generated and my function is not called.

 

Next thing I'd like to know is how I can write back the changed checkbox value to the db. I guees I have to write a supporting save() function in my controller extension.

 

Can someone help me?

 

Here's an excerpt from my code:

 

<script>
function rerenderMap(cb, id)
{
// ... do something with cb.checked on record with id
}
</script>

<apex:pageBlock title="Kontakte" id="table">
  <apex:form >
     <apex:pageBlockTable value="{!account.Contacts}" var="con">
       <apex:column value="{!con.Name}"/>
       <apex:column value="{!con.MailingStreet}"/>
       <apex:column value="{!con.MailingCity}"/>
       <apex:column value="{!con.Phone}"/>
       <apex:column headerValue="{!$ObjectType.contact.fields.Visit_planned__c.label}">
         <apex:inputCheckbox value="{!con.Visit_planned__c}" onchange="rerenderMap(this, '{!con.Id}')">
           <apex:actionSupport event="onchange" rerender="table"/>
         </apex:inputCheckbox>
       </apex:column>
    </apex:pageBlockTable>
  </apex:form>
</apex:pageBlock>

 

Thanks,

 

Thomas