开发者

How do I dynamically set the 'mode' attribute of a apex:pageBlock in Salesforce Visualforce?

I have the following in my visualforc开发者_开发问答e page:

<apex:pageBlock mode="{!pageBlockMode}">
</apex:pageBlock>

And a custom extension with this apex code:

public string pageBlockMode 
{ 
    get { return 'edit'; } 
}

Does anyone know why this doesn't work? It's simply defaulting to 'detail' mode. Is there a way to dynamically change the 'mode' attribute of a pageBlock?


Hope you know that the MODE represents the default user mode for the pageBlock component's child elements. This value determines whether lines are drawn separating field values. Possible values are: "detail", in which data is displayed to the user with colored lines; "maindetail", in which data is displayed to the user with colored lines and a white background, just like the main detail page for records; and "edit", in which data is displayed to the user without field lines. If not specified, this value defaults to "detail". These lines have nothing to do with requiredness, they are merely visual separators, that make it easier to scan a detail page.


Based on above comment, why not then try creating two different pageblock sections with RENDERED attribute

<apex:pageBlock mode="edit" rendered="{!pageBlockMode=='edit'}">
.....
</apex:pageBlock>

<apex:pageBlock mode="detail" rendered="{!pageBlockMode=='detail'}">
.....
</apex:pageBlock>


It looks like my original code works now. Not sure which version of Visualforce this was fixed/changed in:

Page:

<apex:pageBlock mode="{!pageBlockMode}">
</apex:pageBlock>

Controller:

public string pageBlockMode 
{ 
    get { return 'edit'; } 
}


I think this may help you! It worked for me!

public Component.Apex.PageBlock getPageBlockArea(){
     Component.Apex.PageBlock p = new Component.Apex.PageBlock();
     p.title = 'Working';
     p.mode = 'edit';
     return p;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜