如何动态设置“模式”? Salesforce Visualforce 中 apex:pageBlock 的属性?
我的 Visualforce 页面中有以下内容:
<apex:pageBlock mode="{!pageBlockMode}">
</apex:pageBlock>
以及带有此顶点代码的自定义扩展:
public string pageBlockMode
{
get { return 'edit'; }
}
有谁知道为什么这不起作用?它只是默认为“详细”模式。有没有办法动态更改 pageBlock 的“mode”属性?
I have the following in my visualforce 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
希望您知道 MODE 代表 pageBlock 组件的子元素的默认用户模式。该值确定是否绘制分隔字段值的线。可能的值为:
“详细信息”,其中数据以彩色线条显示给用户;
“maindetail”,其中数据以彩色线条和白色背景向用户显示,就像记录的主要详细信息页面一样;和
“编辑”,其中向用户显示的数据没有字段线。
如果未指定,该值默认为“详细信息”。这些线与需求无关,它们只是视觉分隔符,可以更轻松地扫描详细信息页面。
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.
基于上面的评论,为什么不尝试使用 RENDERED 属性创建两个不同的页面块部分
Based on above comment, why not then try creating two different pageblock sections with RENDERED attribute
看起来我原来的代码现在可以工作了。不确定哪个 Visualforce 版本已修复/更改此问题:
页面:
控制器:
It looks like my original code works now. Not sure which version of Visualforce this was fixed/changed in:
Page:
Controller:
我想这可能对你有帮助!这对我有用!
I think this may help you! It worked for me!