You need to sign in to do that
Don't have an account?
Lovel Panchal
How to make checkboxs selected from apex code
I want that when I am binding by checkboxs at that time only based on condition I can make checkbox by default selected or unslected.
So how can I achieve that
here's my apex code
public List<SelectOption> getChkboxItems() {
List<SelectOption> options = new List<SelectOption>();
for(lovel__Item__c i: getitms()){
boolean x =false;
for(lovel__Item_Manufacture_Mapper__c imm: [SELECT lovel__Item__c FROM lovel__Item_Manufacture_Mapper__c WHERE lovel__Manufacturer__c = :id]){
if(i.Id == imm.lovel__Item__c) {
x=true;
}
}
options.add(new SelectOption(i.Id,i.Name,x));
}
return options;
}
So how can I achieve that
here's my apex code
public List<SelectOption> getChkboxItems() {
List<SelectOption> options = new List<SelectOption>();
for(lovel__Item__c i: getitms()){
boolean x =false;
for(lovel__Item_Manufacture_Mapper__c imm: [SELECT lovel__Item__c FROM lovel__Item_Manufacture_Mapper__c WHERE lovel__Manufacturer__c = :id]){
if(i.Id == imm.lovel__Item__c) {
x=true;
}
}
options.add(new SelectOption(i.Id,i.Name,x));
}
return options;
}
In VF Page, set the value as follows:
Accordingly, the checkbox would appear selected or un selected.
Hit LIKE, it this helps. Select it as Best Answer if it solves your problem.