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
msb-appsupport1.3905906418879758E12msb-appsupport1.3905906418879758E12 

How to check whatever I want from a list?


Hi, 
I have displayed a list of result. And I want to check the on I want with a check function. 

How could I do it?

Thanks so much.

The below is related code.

<apex:pageblockSection columns="2" id="result_section">
            <apex:pageblockTable value="{!ticket_result_list}" var="tItem" id="result_table">
                <apex:column headerValue="Ticket Search Result">
                    <apex:outputText value="No result" rendered="{!NOT(found)}"/>
                    <apex:outputText value="{!tItem.name}" rendered="{!found}"/>
                </apex:column>
                <apex:column headerValue="Check-in">
                     <apex:commandButton action="{!check}" value="Check-in" reRender="ticket_check_in"/>
                </apex:column>
                <apex:column headerValue="Uncheck">
                    <apex:commandButton action="{!uncheck}" value="Uncheck" reRender="ticket_check_in"/>
                </apex:column>
            </apex:pageblockTable>
        </apex:pageblockSection>

public PageReference check() {
        //what should I do here to check the on I want.
        update ticketFound;
        return null;
    }

The following is the result list.
User-added image
Sonam_SFDCSonam_SFDC
Instead of using the Checkin button, I would suggest you to go with the wrapper class to have the checkbox to be able to capture the checked records and process it further:

see the below link from Help and training- it explains the concept of wrapper class and gives a sample code which you can implement in your code:
http://wiki.developerforce.com/page/Wrapper_Class
msb-appsupport1.3905906418879758E12msb-appsupport1.3905906418879758E12
I have tried the wrapper class.
However, i could not update the selected value of checkbox.
That is, I could not update the selected field.

It seems when I check the checkbox, the value {!tItem.selectedCheck} and {!tItem.selectedUnCheck} could not got update.

Could anyone tell me how to solve it?

Thanks so much.

The following is my code:

<!-- display the result and check-in -->
        <apex:pageblockSection columns="2" id="result_section">
            <apex:pageblockTable value="{!ticket_result_list}" var="tItem" id="result_table">
                <apex:column headerValue="Ticket Search Result">
                    <apex:outputText value="No result" rendered="{!NOT(found)}"/>
                    <apex:outputText value="{!tItem.ticket.name}" rendered="{!found}"/>
                </apex:column>
             
                <!-- check box to select which the user want to check-->
                <apex:column headerValue="Check-in">
                    <apex:inputCheckbox value="{!tItem.selectedCheck}"/>
                </apex:column>
                <apex:column headerValue="Uncheck">
                    <apex:inputCheckbox value="{!tItem.selectedUncheck}"/>
                </apex:column>

                <!--
                <apex:column headerValue="Check-in">
                     <apex:commandButton action="{!check}" value="Check-in" reRender="result_table"/>
                </apex:column>
                <apex:column headerValue="Uncheck">
                    <apex:commandButton action="{!uncheck}" value="Uncheck" reRender="result_table"/>
                </apex:column>
                -->
            </apex:pageblockTable>
        </apex:pageblockSection>
            <p />
            <apex:commandButton action="{!check}" value="Check-in" reRender="result_table"/>
            <p />
            <apex:commandButton action="{!uncheck}" value="Uncheck" reRender="result_table"/>
        </apex:pageBlock>

--------------------------------------------------------------------------------------------------------------------------------

//check button and uncheck button
    public PageReference check() {
        List<DisplayTicket> selectedTickets = new List<DisplayTicket>();
     
        for(DisplayTicket selectTic: getTicket_result_List()) {
            if(selectTic.selectedCheck == True) {
                selectTic.ticket.sbxe1__sbx_Attended__c = TRUE;
                update selectTic.ticket;
            }
        }
     
        selectedTickets = null;

        return null;
    } 

    public PageReference uncheck() {
        List<DisplayTicket> selectedTickets = new List<DisplayTicket>();
     
        for(DisplayTicket selectTic: getTicket_result_List()) {
            if(selectTic.selectedCheck == FALSE && selectTic.selectedUncheck == TRUE) {
                selectTic.ticket.sbxe1__sbx_Attended__c = FALSE;
                update selectTic.ticket;
            }
        }
     
        selectedTickets = null;

        return null;
    }

public class DisplayTicket {
        public sbxe1__Ticket__c ticket {
            get; set;
        }
        public Boolean selectedCheck {
            get; set;
        }
        public Boolean selectedUncheck {
            get; set;
        }     
        public DisplayTicket(sbxe1__Ticket__c item) {
            this.ticket = item;
            selectedCheck = false;
            selectedUncheck = false;
            //this.no_found_msg = 'No result';
        }
        public String name {
            get {return ticket.Name;}
        }
        public String no_found_msg {
            get {return 'No result';}
        }

    }