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
hacksawblade16hacksawblade16 

set checkbox value to checked

i have checkboxes in column header inside pageblocktable. I rerender the table when the checkbox is checked.after rerendering i want the checkbox to remian in the checked state,but it gets unchecked.How can i keep it checked??

imutsavimutsav
could you please share the code
codeshodecodeshode

@hacksawblade16

 

Hey the issue, as i perceive is that  you are trying to rerender the same table, whose header checkbox is checked(by the user)

 

Now as you rerender the table, thye column header also refreshes, and hence the check is gone.

 

Now if this is what the scenario is. Then i can advise you few steps you can take:

  1. Make a boolean property on your controller, ex: 
public Boolean isColumnValueChecked {get; set;}

    and then on your page

    you will bind this boolean to your checkbox

<apex:inputCheckBox value="{!isColumnValueChecked}">
    <apex:actionSupport event="onchange" reRender="tablePanel"/>
</apex:inputCheckBox>

    Now what this does is, it will submit your form and you will get a the checkbox checked again, once it is rerendered

 

 2.  Or else you can have a different column header and different table body section, and make sure you refresh only the        table. This will be a little extra work but at the end of the day, it might solve your issue.

 

 

I hope, I understood your problem correctly. If yes, do let me know if you get any problem implementing any of the above steps. And if no, then i would love to hear from you.

hacksawblade16hacksawblade16
Hey Thanks for the reply,The problem is i'm putting the checkbox inside my column header with the use of facet .now if i need to have an action support for my checkbox then i need to put the action support tag inside the facet as well.It will be something like this . After doing this the inputcheckbox becomes invisible .It is not displayed on the page.If i remove action support from facet then the checkbox is displayed again.
codeshodecodeshode
Hey I think you tried pasting the code, but its not added. Can you please add the piece of code you have used
hacksawblade16hacksawblade16
<apex:column>
<Apex:facet name=header">
<apex:inputCheckBox value="{!isColumnValueChecked}"/>
<apex:actionSupport event="onchange" reRender="tablePanel"/>
</Apex:facet>
<apex:column>
codeshodecodeshode

Oh thats the thing,

 

actionsuppport has to be inside the checkbox, like this.

<apex:facet name="header">
    <apex:inputCheckbox value="{!someboolean}">
        <apex:actionSupport action="{!doSomething}" reRender="tablePanel"/>
    </apex:inputCheckbox>
</apex:facet>

 Try this, hopefully your problem will be solved. ;)

codeshodecodeshode
hey don't forget to add the event, i missed on my code ;)
hacksawblade16hacksawblade16
Thank you, I think I have tried it that way as well. I do not remember though.I shall give a try once again 2moro and i'll get back to you.
codeshodecodeshode
perfect, do let me know if it behaves otherwise, will be happy to help