Kentico 如何使筛选器与事件日历Web部件一起工作?
我创建了一个自定义事件文档,它扩展了普通事件文档的字段。我添加了一个字段,可以在管道分隔列表中保留0到多个类别ID。类别存储在自定义表中 这是我的过滤代码:Kentico 如何使筛选器与事件日历Web部件一起工作?,kentico,Kentico,我创建了一个自定义事件文档,它扩展了普通事件文档的字段。我添加了一个字段,可以在管道分隔列表中保留0到多个类别ID。类别存储在自定义表中 这是我的过滤代码: public partial class CMSGlobalFiles_EventCategoryFilter : CMSAbstractDataFilterControl { protected void Page_Load(object sender, EventArgs e) { } protect
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,问题在于EventCalendar的不同生命周期,基于基于标准.Net Calendar的CMSCalendar控件 首先,我们的开发人员发现了一种方法来解决这个问题,并允许您的场景在默认情况下运行。此修复程序将包含在6.0.33热修复程序中(计划于周五25日发布)。 很抱歉给您带来不便 除了这个即将到来的修复之外,还可以通过修改(克隆)web部件,将过滤控件直接集成到该web部件中,并在OnPreRender中将日历的Where条件设置为数据绑定之前,使EventCalendar过滤其结果
protected override void OnPreRender(EventArgs e)
{
calItems.WhereCondition = "some filtering condition";
...
如果你能热修复你的CMS实例,肯定会少花点力气
问候,
Zdenek/Kentico支持问题在于基于标准.Net日历的CMSCalendar控件的EventCalendar的不同生命周期 首先,我们的开发人员发现了一种方法来解决这个问题,并允许您的场景在默认情况下运行。此修复程序将包含在6.0.33热修复程序中(计划于周五25日发布)。 很抱歉给您带来不便 除了这个即将到来的修复之外,还可以通过修改(克隆)web部件,将过滤控件直接集成到该web部件中,并在OnPreRender中将日历的Where条件设置为数据绑定之前,使EventCalendar过滤其结果
protected override void OnPreRender(EventArgs e)
{
calItems.WhereCondition = "some filtering condition";
...
如果你能热修复你的CMS实例,肯定会少花点力气
问候,
Zdenek/Kentico支持