I have an sObject custom_obj__c
with a multi-select picklist field items_list__c
and its values (items) are (item1 list
, item2 list
, item3 list
,..), and checkbox fields (item1_list__c
, item2_list__c
, item3_list__c
,..) for each item in the picklist. I need do display the checkboxes on my visualforce page which have the same values selected in the picklist.
In my controller I've got the selected items from the picklist and stored them in a list of strings and I updated the values to replace spaces with underscore _
and append __c
at the end of the string. This list I made to build the query to get the checkboxes.
String selectedItemsQuery = 'item1_list__c,item2_list__c';
String finalQuery = 'SELECT '+ selectedItemsQuery +' FROM custom_obj__c WHERE Id=\''+ObjId+'\';
and then I execute a select query statement to get record value
custom_obj__c targetObj = Dabase.query(finalQuery);
So now I've got the values of selected checkboxes, how can I display only these checkboxes and not the whole list of checkboxes on the visualforce page??
<apex:pageBlock>
<apex:pageBlockSection title="List of checkboxes selected from list">
<!-- Checkboxes inputFields should display here -->
</apex:pageBlockSection>
</apex:pageBlock>