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
Avi646Avi646 

Please suggest how to show a matrix of checkbox in VF

 



SidzSidz
In a VF page if you want to display some content from back-end in matrix form you can use a List> and loop through that list in the VF page. if you want to simply display a matrix of checkboxes as in 'tictactoe' game you can use javascript to print that <script> document.write('
'; for(var i=0;i<3;i++) { document.write('
'; for(var i=0;i<3;i++) { document.write(' '); } document.write(''; } document.write(''; </script> hope this helps
Avi646Avi646

Actually i was trying to do with the help of wrapper class which includes a list of boolean value. I wasnt able to show using inputcheckbox but when i used outputfield i was able to show the values....

Avi646Avi646

Here is the Page

<apex:page controller="chkBox">
 <apex:form >
<apex:pageBlock >
  <apex:pageBlockTable value="{!getVal}" var="p" >
  <apex:repeat value="{!p.box}" var="a">
    
    <apex:column >
    <apex:inputCheckbox value="{!a}"/>
    </apex:column>
    
   </apex:repeat>
   </apex:pageBlockTable>
   <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/></apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

 Controller:

 

public class chkBox {
list<wrapbox>  wrp= new list<wrapbox>();
    public PageReference save() {
    String test = ApexPages.currentPage().getParameters().get('test');
    system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'+test);
        return null;
    }


    public  list<wrapbox> getGetVal() {
     system.debug('::::::::::::::::::::::::::::::'+wrp);
    wrapbox mywrp = new wrapbox();
    for(integer i =0;i <10; i++){
    mywrp = new wrapbox();
    for(integer j =0;j <10; j++){
    mywrp.box.add(true);
    }
    wrp.add(mywrp);
    }
        return wrp;
    }

}

 Wrapper class:

 

 

public class wrapBox{
public List<Boolean> box{get;set;} 
public wrapBox(){
box = new List<Boolean>();
}
}

 

 

 

this code was written for some testing but i am unable to implement checkbox its giving error unknown property. whereas i am able to show it using outputtext.

Please suggest