0

Long time no see. I've got a question about iterating cancel button on the visualforce page. Here is the code:

Apex Controller:(This is for finding class from Teacher_Schedule__c, which is a custom object)

    private PageReference findClass(){
    String classtype = ts.ClassType__c;
    Datetime classstarttime = ts.Start_Time__c;
    Datetime classseventime = classstarttime.addHours(168);

    String schedulequery = 'SELECT Id, Name, Subject__c, ClassType__c, Center__c, Start_Time__c, End_Time__c FROM Teacher_Schedule__c ' 
    + 'WHERE Start_Time__c >= :classstarttime AND Start_Time__c <= :classseventime ';

    System.debug('citiesCondition size : ' + this.citiesCondition.size());

    if(String.isBlank(selectedCenter)){
        schedulequery += ' AND Center__c IN :citiesCondition ';
    }else {
        schedulequery += ' AND Center__c = :selectedCenter ';
    }
    if (classtype != null) {
        schedulequery += ' AND ClassType__c = :classtype';
    }
    System.debug('schedulequery : ' + schedulequery);
    scheduleList = Database.query(schedulequery);
    System.debug('====scheduleList=' + scheduleList.size());

    return ApexPages.currentPage();

}

Visualforce: (For displaying classes I've found)

        <apex:pageBlock title="Search Results">
            <apex:pageBlockTable value="{!scheduleList}" var="s">
                <apex:column value="{!s.Name}" />
                <apex:column value="{!s.ClassType__c}" />
                <apex:column value="{!s.Center__c}" />
                <apex:column value="{!s.Subject__c}" />
                <apex:column value="{!s.Start_Time__c}" />
                <apex:column value="{!s.End_Time__c}" />
                <apex:column>
                    <apex:commandLink  value="Book" action="{!doAction}" onclick="return setActionEvent('Page:Form:actionEvent','book')" styleClass="btn" style="text-decoration: none" >
                        <apex:param value="{!s.Id}" assignTo="{!scheduleid}" name="scheduleid" />
                    </apex:commandLink>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>

Right now, the page looks like this, which is perfect I think, but I do wanna either hide the record has been booked or replace the book button with cancel.

I can realize that I need to iterate the schedulelist again to get each reacord and identify whether the class has been booked or not, but I cannot really make it happen. Any idea about this?

Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.