0

我正在尝试构建一个 Visualforce 页面,我想在其中以表格格式显示系统中的所有 sObject 及其相关数据计数。

ObjectName ObjectLabel RecordCount

我能知道如何查询所有 sObjects 的列表并显示在页面中吗?

4

1 回答 1

0

这是一个获取所有对象列表的示例代码(在这种情况下,将它们添加到选择列表中)。

public class objectList{

 public String val {get;set;}

    public List<SelectOption> getName()
    {
      List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();     
      List<SelectOption> options = new List<SelectOption>();

      for(Schema.SObjectType f : gd)
      {
        options.add(new SelectOption(f.getDescribe().getLabel(),f.getDescribe().getLabel()));
      }
      return options;
    }
}

由于您无法预测对象的数量,因此您不能使用标准的 tabPanel 标记,但您必须使用 Dynamic Visualforce。一些关于在动态 VF 中使用选项卡的 文档

但是,您为什么要选择标签?为什么不在 1 页上显示完整的结果集?这将为您节省一些使用动态 Visualforce 组件(不易使用)的麻烦。

于 2013-05-17T07:45:57.917 回答