来自多列表中所选项目的Sitecore数据源

时间:2014-12-02 11:30:52

标签: sitecore sitecore6

我有一个包含多列表的页面

My Multilist

我想创建第二个多列表,其中包含上一个列表的选定值(并在修改第一个多列表时反映第二个多列表中的更改)。

  • 活动
  • Lonely planet Denmark

我该怎么做?

1 个答案:

答案 0 :(得分:2)

您需要扩展MultiListEx字段并添加动态源在DoRender事件中,您的代码应该是:

public class CustomMultiList : MultilistEx
{
  private void GenerateDynamicDatasource()
  {
    //write some code to get the selected IDs from the first multilist field
    //build a string with this query format :
    // string EncludedIDsQuery = "@@id == '[First Selected Guid]' or @@id == '[secondSelected Guid]'" and so on
    this.Source = "query:" + this.Source + "/*[" + EncludedIDsQuery+ "]";
  }

  protected override void DoRender(output)
  {
    this.GenerateDynamicDatasource();
    base.DoRender(output);
  }
}

希望这有帮助!

<强>更新

Keven有更多可重复使用的解决方案,我认为它也适用于您的情况: https://stackoverflow.com/a/25785363/2074649

相关问题