1

I am passing a list to the pageblock table and my table looks like below enter image description here

i want to edit the table values. I tried the below code. This is my VF Page code

<apex:pageBlockSection id="section2" columns="2" collapsible="true" title="Configure Complexity">
    <apex:pageBlockTable style="margin-left: 80%;width:30%" value="{!LMComplexity}" var="com">
        <apex:inlineEditSupport showOnEdit="update, cancelButton"
                                hideOnEdit="editButton" event="ondblclick"
                                changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"></apex:inlineEditSupport>
        <apex:column headerValue="Class" value="{!com.Class__c}" />
        <apex:column headerValue="Maximum Days" value="{!com.Maximum_Complexity_Score__c}"/>
        <apex:column headerValue="Minimum Days" value="{!com.Minimum_Complexity_Score__c}"/>
        
    </apex:pageBlockTable>
    <apex:commandButton id="update" action="{!quickUpdat}"/>
</apex:pageBlockSection>

and my controller code looks like this

public class profileList {
    public profileList(ApexPages.StandardController controller) {}
    public List <LM_Default_Weightage__mdt> result{get;set;}
    Boolean testval = false;
            
    public profileList() {
        result= Database.query('Select Class__c, Maximum_Complexity_Score__c,Minimum_Complexity_Score__c From LM_Default_Complexity__mdt');
    }
    public PageReference quickUpdat() {
        try {
            return ApexPages.CurrentPage();
        } catch(Exception e) {
            System.debug('@@@Error');
            return null;
        }
    }
    public list<LM_Default_Complexity__mdt> getLMComplexity() {
        List<LM_Default_Complexity__mdt> comp=  [Select Class__c, Maximum_Complexity_Score__c,Minimum_Complexity_Score__c From LM_Default_Complexity__mdt];
        return comp;
    }
}

So basically i am querying my custom metadata put it in a list and returned it.Finally displaying the returned list in pageblock table. Is the table editable?

Note: I tried directly passing the custom metadata and i cannot edit the table.Custom metadata isn't editable

2
  • Using wrapper class and add checkbox for all rows you can edit it inline. Feb 5 '19 at 10:41
  • Can you please provide me some samples? It would be helpful
    – SKH
    Feb 5 '19 at 12:26
0

Use an apex:inputField inside the column.

<apex:column headerValue="Maximum Days">
 <apex:inputField value="{!com.Maximum_Complexity_Score__c}"/>
</apex:column>
<apex:column headerValue="Minimum Days">
 <apex:inputField value="{!com.Minimum_Complexity_Score__c}"/>
</apex:column>
3
  • It didn't work either.I am passing a list to this pageblock table
    – SKH
    Feb 5 '19 at 14:59
  • @SKH Yes, that should work. What's the problem you're experiencing?
    – sfdcfox
    Feb 5 '19 at 15:08
  • When i double click on the table row it is not in edit mode. I cannot edit any vaues in the table
    – SKH
    Feb 5 '19 at 15:16
0

Based on the code you provided in your post, can you confirm if you are planning for inline edit on Custom Metadata Type records or Custom object record?

Here is an example code from Salesforce developer guide that shows inline editing. Can you try like below?

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_inline_editing.htm

<apex:page standardController="Account" recordSetVar="records" id="thePage"> 
    <apex:form id="theForm"> 
        <apex:pageBlock id="thePageBlock"> 
            <apex:pageBlockTable value="{!records}" var="record" id="thePageBlockTable"> 
                <apex:column >
                    <apex:outputField value="{!record.Name}" id="AccountNameDOM" /> 
                    <apex:facet name="header">Name</apex:facet>
                </apex:column>
                <apex:column >
                    <apex:outputField value="{!record.Type}" id="AccountTypeDOM" /> 
                    <apex:facet name="header">Type</apex:facet>
                </apex:column>
                <apex:column >
                    <apex:outputField value="{!record.Industry}" 
                        id="AccountIndustryDOM" />  
                        <apex:facet name="header">Industry</apex:facet>
                </apex:column>
                <apex:inlineEditSupport event="ondblClick" 
                        showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" /> 
            </apex:pageBlockTable> 
            <apex:pageBlockButtons > 
                <apex:commandButton value="Edit" action="{!save}" id="editButton" />
                <apex:commandButton value="Save" action="{!save}" id="saveButton" />
                <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton" />
            </apex:pageBlockButtons> 
        </apex:pageBlock> 
    </apex:form>
</apex:page>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.