2017-05-09 67 views
1

我有一个自定义表格,其中有几个字段具有列表选项供用户从添加内容时进行选择。在API中是否有某些东西允许我访问特定字段的选项,以便我可以在过滤小部件中使用这些相同的选项? List Example在Kentico 10自定义表中的字段的访问列表选项

像下面这样的东西,但适用于自定义表中的字段?

var guids = ParentDocument.GetValue("CustomFieldName").Split(';'); 
 
var referencedDocs = DocumentHelper.GetDocuments().WhereIn("DocumentGuid", guids);

UPDATE - 的情况下,该代码在回答修改链接:

protected string[] GetFormFieldOptions() 
 
    { 
 
     DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo("custom.MyPageTypeName"); 
 
     if (dci != null) 
 
     { 
 
      //Get the data from the form field 
 
      FormInfo fi = new FormInfo(dci.ClassFormDefinition); 
 
      FormFieldInfo ffi = fi.GetFormField("Industry"); 
 
      string[] industries = ffi.Settings["Options"].ToString().Split('\n'); 
 
      return industries; 
 
     } 
 
     return null; 
 
    }

回答

1

使用DataClassInfoProvider为了获得您需要的数据。查看this blog post查看更多详情。

+0

该代码是我需要的!谢谢! –

0

,你在你的问题都可以使用相同的代码。所不同的是,你需要获得2个不同的东西是不可用的“页面”或“文档”的水平:

  1. 自定义表对象
  2. 自定义表项基于#1

您可以使用API​​来获取定制的表项:

var cti = CustomTableItemProvider.GetItem(<id or guid>, "yourcustom.tableclassname); 
if (cti != null) 
{ 
    string[] s = ValidationHelper.GetString(cti.GetValue("YourField"), "").Split(";"); 
} 

更新
戈t一个字段中的动态选项列表,您可以简单地使用列表控件(如下拉列表或单选按钮列表)作为您的控件。一个文本框)。然后在下拉列表的属性中,可以将其设置为查询。在查询输入类似

-- if you wan to have a 'select one' add this 
SELECT '', '-- select one --' 
UNION 
SELECT ItemID, FieldName 
FROM CustomTable_Name 
ORDER BY 2 
+0

不幸的是,那只能让我获得自定义表项的选定值。我想获得特定自定义字段的所有可用选项。所以我正在寻找一些方法来访问表格上的自定义属性的选项,而不是表格项目。 –

+0

你的领域使用什么数据源?我假设这是一个复选框列表或列表框是否正确?那些来自另一个定制表的值是多少?如果是这样,那么只需运行相同的查询来获取这些值。 –

+0

目前,它们只是该领域本身的一个选项列表。 –

相关问题