在 Sitecore 的帮助下,我想通了。基本上你必须创建一个继承自 MultilistEx 的自定义控件。然后您需要覆盖 DoRender() 事件。在调用 base.DoRender() 之前,您必须更改源 (this.Source) 以使用 Sitecore 查询。以前我试图在 OnLoad 事件中这样做。所以我的代码现在看起来像这样:
public class CustomMultiList : MultilistEx
{
private void ExcludeItems()
{
...custom code here that builds a list of Item IDs to exclude from the Multilist source...
...list should look like this "@@id != 'some guid' and @@id != 'some guid' and so forth...
...you could also build a list of item ids to include. Any Sitecore query will do...
...you can use this.ItemID to get a reference to the current item that is being edited in the Content Editor...
this.Source = "query:" + this.Source + "/*[" + myListOfItemIdsToExclude + "]";
}
protected override void DoRender(output)
{
this.ExcludeItems();
base.DoRender(output);
}
}