如下图,在标准ListView中,表示项目和表示条件可以自由设定,现需求选择特定数据,点击ListView Button,取得当前选定的数据并表示在画面上。
实现方法
使用【getSelected()】方法可以取得选择的record的数据
参考文档:StandardSetController Class | Apex Reference Guide | Salesforce Developers
1.Visualforce Page做成
getAccountListForVf.page
<apex:page standardController="Account" recordSetVar="accounts" extensions="ListViewButtonDemo" showHeader="false">
<apex:form >
<html>
<head>
</head>
<body>
<apex:pageMessages />
<table>
<tr>
<th>Name</th>
</tr>
<apex:repeat value="{!accounts}" var="o">
<tr>
<td>
<apex:inputField value="{!o.Name}"/>
</td>
<td>
<apex:inputField value="{!o.Id}"/>
</td>
<td>
<apex:inputField value="{!o.Industry}"/>
</td>
</tr>
</apex:repeat>
</table>
</body>
<apex:commandButton value="Save Changes" action="{!save}"/>
</html>
</apex:form>
</apex:page>
getAccountListForVf.page-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>56.0</apiVersion>
<availableInTouch>false</availableInTouch>
<confirmationTokenRequired>false</confirmationTokenRequired>
<label>getAccountListForVf</label>
</ApexPage>
ListViewButtonDemo.cls
public class ListViewButtonDemo {
public List<Account> accounts{get;private set;}
public ListViewButtonDemo(ApexPages.StandardSetController stdSetController){
accounts = (List<Account>) stdSetController.getSelected();
}
public PageReference save(){
try{
update accounts;
} catch(Exception e){
System.debug('Exception: ' + e);
}
return null;
}
}
2.List View Button做成
注意:【チェックボックスの表示】要选上,不然ListView上边不能表示checkbox
效果展示
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。