2012-05-09 10 views
1

私は、通常のイベントドキュメントのフィールドを拡張するカスタムイベントドキュメントを作成しました。私は、パイプで区切られたリスト内の多くのカテゴリIDに0を保つことができるフィールドを追加しました。カテゴリはカスタムテーブルに格納されます。イベントカレンダーWebパーツでフィルタを使用するにはどうすればよいですか?

public partial class CMSGlobalFiles_EventCategoryFilter : CMSAbstractDataFilterControl 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 

    } 

    protected override void OnInit(EventArgs e) 
    { 
     SetupControl(); 

     base.OnInit(e); 
    } 

    protected override void OnPreRender(EventArgs e) 
    { 
     if (RequestHelper.IsPostBack()) 
     { 
      setFilter(); 
     } 

     base.OnPreRender(e); 
    } 

    private void SetupControl() 
    { 
     if (this.StopProcessing) 
     { 
      this.Visible = false; 
     } 

     else if (!RequestHelper.IsPostBack()) 
     { 
      InitializeCategory(); 
     } 

    } 

    private void InitializeCategory() 
    { 
     CustomTableItemProvider customTableProvider = ne CustomTableItemProvider(CMSContext.CurrentUser); 

     string where = ""; 

     string tableName = "customtable.EventCategory"; 

     DataClassInfo customTable = DataClassInfoProvider.GetDataClass(tableName); 

     if (customTable != null) 
     { 

      DataSet dataSet = customTableProvider.GetItems(tableName, where, null); 

      if (!DataHelper.DataSourceIsEmpty(dataSet)) 
      { 
       this.drpCategory.DataSource = dataSet; 
       this.drpCategory.DataTextField = "CategoryName"; 
       this.drpCategory.DataValueField = "ItemGUID"; 

       this.drpCategory.DataBind(); 

       this.drpCategory.Items.Insert(0, new ListItem("(all)", "##ALL##")); 
      } 
     } 

    } 

    private void setFilter() 
    { 
     string where = null; 

     if (this.drpCategory.SelectedValue != null) 
     { 
      Guid itemGUID = ValidationHelper.GetGuid(this.drpCategory.SelectedValue, Guid.Empty); 

      if (itemGUID != Guid.Empty) 
      { 
       where = "EventCategory LIKE \'%" + itemGUID.ToString() + "%\'"; 
      } 

     } 

     if (where != null) 
     { 
      this.WhereCondition = where; 
     } 

     this.RaiseOnFilterChanged(); 
    } 

} 

このフィルタは、基本的なリピータと文書データソースを使用して素晴らしい作品:

はここに私のフィルタコードです。私がイベントカレンダーを使用するとき、それはしません。私はKenticoバージョン6.0.30を使用しています。

答えて

1

問題は、標準の.Netカレンダーに基づくCMSCalendarコントロールに基づくEventCalendarのライフサイクルが異なります。

まず、開発者はこれを修正し、シナリオをデフォルトで実行する方法を発見しました。この修正は6.0.33の修正プログラム(金曜日25日に予定されています)に含まれます。 このご迷惑をおかけして申し訳ありません。

次回の修正とは別に、Webパーツを変更(複製)し、フィルタコントロールをそのWebパーツに直接統合し、OnPreRenderのカレンダーのWhere条件をOnPreRenderに設定することで、結果をフィルタリングすることもできますDataBind

protected override void OnPreRender(EventArgs e) 
{ 
    calItems.WhereCondition = "some filtering condition"; 
    ... 

CMSインスタンスを修正することができれば、それほど労力はかかりません。

よろしく、

ズデニェク/ Kenticoサポート

関連する問題