本文整理汇总了C#中Rock.Web.UI.Controls.FilterField.SetSelection方法的典型用法代码示例。如果您正苦于以下问题:C# FilterField.SetSelection方法的具体用法?C# FilterField.SetSelection怎么用?C# FilterField.SetSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Web.UI.Controls.FilterField
的用法示例。
在下文中一共展示了FilterField.SetSelection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFilterControl
/// <summary>
/// Creates the filter control.
/// </summary>
/// <param name="parentControl">The parent control.</param>
/// <param name="filter">The filter.</param>
/// <param name="filteredEntityTypeName">Name of the filtered entity type.</param>
/// <param name="setSelection">if set to <c>true</c> [set selection].</param>
/// <param name="rockContext">The rock context.</param>
private void CreateFilterControl( Control parentControl, DataViewFilter filter, string filteredEntityTypeName, bool setSelection, RockContext rockContext )
{
try
{
if ( filter.ExpressionType == FilterExpressionType.Filter )
{
var filterControl = new FilterField();
parentControl.Controls.Add( filterControl );
filterControl.DataViewFilterGuid = filter.Guid;
filterControl.ID = string.Format( "ff_{0}", filterControl.DataViewFilterGuid.ToString( "N" ) );
filterControl.FilteredEntityTypeName = filteredEntityTypeName;
if ( filter.EntityTypeId.HasValue )
{
var entityTypeCache = Rock.Web.Cache.EntityTypeCache.Read( filter.EntityTypeId.Value, rockContext );
if ( entityTypeCache != null )
{
filterControl.FilterEntityTypeName = entityTypeCache.Name;
}
}
filterControl.Expanded = filter.Expanded;
if ( setSelection )
{
try
{
filterControl.SetSelection( filter.Selection );
}
catch ( Exception ex )
{
this.LogException( new Exception("Exception setting selection for DataViewFilter: " + filter.Guid, ex));
}
}
filterControl.DeleteClick += filterControl_DeleteClick;
}
else
{
var groupControl = new FilterGroup();
parentControl.Controls.Add( groupControl );
groupControl.DataViewFilterGuid = filter.Guid;
groupControl.ID = string.Format( "fg_{0}", groupControl.DataViewFilterGuid.ToString( "N" ) );
groupControl.FilteredEntityTypeName = filteredEntityTypeName;
groupControl.IsDeleteEnabled = parentControl is FilterGroup;
if ( setSelection )
{
groupControl.FilterType = filter.ExpressionType;
}
groupControl.AddFilterClick += groupControl_AddFilterClick;
groupControl.AddGroupClick += groupControl_AddGroupClick;
groupControl.DeleteGroupClick += groupControl_DeleteGroupClick;
foreach ( var childFilter in filter.ChildFilters )
{
CreateFilterControl( groupControl, childFilter, filteredEntityTypeName, setSelection, rockContext );
}
}
}
catch ( Exception ex )
{
this.LogException( new Exception( "Exception creating FilterControl for DataViewFilter: " + filter.Guid, ex ) );
}
}
示例2: CreateFilterControl
/// <summary>
/// Creates the filter control.
/// </summary>
/// <param name="parentControl">The parent control.</param>
/// <param name="filter">The filter.</param>
/// <param name="reportEntityType">Type of the report entity.</param>
/// <param name="filteredEntityTypeName">Name of the filtered entity type.</param>
/// <param name="setSelection">if set to <c>true</c> [set selection].</param>
/// <param name="selectedDataFieldGuids">The selected data field guids.</param>
/// <param name="configurableDataFieldGuids">The configurable data field guids.</param>
/// <param name="rockContext">The rock context.</param>
private void CreateFilterControl(
Control parentControl,
DataViewFilter filter,
EntityType reportEntityType,
bool setSelection,
List<Guid> selectedDataFieldGuids,
List<Guid> configurableDataFieldGuids,
List<Guid> togglableDataFieldGuids,
RockContext rockContext )
{
try
{
var filteredEntityTypeName = EntityTypeCache.Read( reportEntityType ).Name;
if ( filter.ExpressionType == FilterExpressionType.Filter )
{
var filterControl = new FilterField();
filterControl.FilterMode = FilterMode.SimpleFilter;
bool filterIsVisible = selectedDataFieldGuids.Contains( filter.Guid );
bool filterIsConfigurable = configurableDataFieldGuids.Contains( filter.Guid );
bool showCheckbox = togglableDataFieldGuids.Contains( filter.Guid ) || !filterIsConfigurable;
filterControl.Visible = filterIsVisible;
parentControl.Controls.Add( filterControl );
filterControl.DataViewFilterGuid = filter.Guid;
filterControl.HideFilterCriteria = !filterIsConfigurable;
filterControl.ID = string.Format( "ff_{0}", filterControl.DataViewFilterGuid.ToString( "N" ) );
filterControl.FilteredEntityTypeName = filteredEntityTypeName;
if ( filter.EntityTypeId.HasValue )
{
var entityTypeCache = Rock.Web.Cache.EntityTypeCache.Read( filter.EntityTypeId.Value, rockContext );
if ( entityTypeCache != null )
{
filterControl.FilterEntityTypeName = entityTypeCache.Name;
}
}
filterControl.Expanded = true;
filterControl.ShowCheckbox = filterIsVisible && showCheckbox;
var reportEntityTypeCache = EntityTypeCache.Read( reportEntityType );
var reportEntityTypeModel = reportEntityTypeCache.GetEntityType();
var filterEntityType = EntityTypeCache.Read( filter.EntityTypeId ?? 0 );
var component = Rock.Reporting.DataFilterContainer.GetComponent( filterEntityType.Name );
if ( component != null )
{
string selectionUserPreference = null;
bool? checkedUserPreference = null;
if ( setSelection && filterIsVisible && filterIsConfigurable )
{
selectionUserPreference = this.GetUserPreference( string.Format( "{0}_{1}_Selection", GetReportDataKeyPrefix(), filterControl.DataViewFilterGuid.ToString( "N" ) ) );
}
else if ( setSelection && filterIsVisible && !filterIsConfigurable )
{
checkedUserPreference = this.GetUserPreference( string.Format( "{0}_{1}_Checked", GetReportDataKeyPrefix(), filterControl.DataViewFilterGuid.ToString( "N" ) ) ).AsBooleanOrNull();
}
if ( checkedUserPreference.HasValue )
{
filterControl.SetCheckBoxChecked( checkedUserPreference.Value );
}
if ( filterIsVisible && !filterIsConfigurable )
{
// not configurable so just label it with the selection summary
filterControl.Label = component.FormatSelection( reportEntityTypeModel, filter.Selection );
}
else if ( component is Rock.Reporting.DataFilter.PropertyFilter )
{
// a configurable property filter
var propertyFilter = component as Rock.Reporting.DataFilter.PropertyFilter;
if ( setSelection )
{
var selection = filter.Selection;
if ( !string.IsNullOrWhiteSpace( selectionUserPreference ) )
{
selection = propertyFilter.UpdateSelectionFromUserPreferenceSelection( selection, selectionUserPreference );
}
selection = propertyFilter.UpdateSelectionFromPageParameters( selection, this );
try
{
filterControl.SetSelection( selection );
}
//.........这里部分代码省略.........
示例3: CreateFilterControl
/// <summary>
/// Creates the filter control.
/// </summary>
/// <param name="parentControl">The parent control.</param>
/// <param name="filter">The filter.</param>
/// <param name="setSelection">if set to <c>true</c> [set selection].</param>
/// <param name="rockContext">The rock context.</param>
private void CreateFilterControl( Control parentControl, DataViewFilter filter, bool setSelection, RockContext rockContext )
{
try
{
if ( filter.ExpressionType == FilterExpressionType.Filter )
{
var filterControl = new FilterField();
parentControl.Controls.Add( filterControl );
filterControl.DataViewFilterGuid = filter.Guid;
filterControl.ID = string.Format( "ff_{0}", filterControl.DataViewFilterGuid.ToString( "N" ) );
// Remove the 'Other Data View' Filter as it doesn't really make sense to have it available in this scenario
filterControl.ExcludedFilterTypes = new string[] { typeof( Rock.Reporting.DataFilter.OtherDataViewFilter ).FullName };
filterControl.FilteredEntityTypeName = ITEM_TYPE_NAME;
if ( filter.EntityTypeId.HasValue )
{
var entityTypeCache = Rock.Web.Cache.EntityTypeCache.Read( filter.EntityTypeId.Value, rockContext );
if ( entityTypeCache != null )
{
filterControl.FilterEntityTypeName = entityTypeCache.Name;
}
}
filterControl.Expanded = filter.Expanded;
if ( setSelection )
{
try
{
filterControl.SetSelection( filter.Selection );
}
catch ( Exception ex )
{
this.LogException( new Exception( "Exception setting selection for DataViewFilter: " + filter.Guid, ex ) );
}
}
filterControl.DeleteClick += filterControl_DeleteClick;
}
else
{
var groupControl = new FilterGroup();
parentControl.Controls.Add( groupControl );
groupControl.DataViewFilterGuid = filter.Guid;
groupControl.ID = string.Format( "fg_{0}", groupControl.DataViewFilterGuid.ToString( "N" ) );
groupControl.FilteredEntityTypeName = ITEM_TYPE_NAME;
groupControl.IsDeleteEnabled = parentControl is FilterGroup;
if ( setSelection )
{
groupControl.FilterType = filter.ExpressionType;
}
groupControl.AddFilterClick += groupControl_AddFilterClick;
groupControl.AddGroupClick += groupControl_AddGroupClick;
groupControl.DeleteGroupClick += groupControl_DeleteGroupClick;
foreach ( var childFilter in filter.ChildFilters )
{
CreateFilterControl( groupControl, childFilter, setSelection, rockContext );
}
}
}
catch ( Exception ex )
{
this.LogException( new Exception( "Exception creating FilterControl for DataViewFilter: " + filter.Guid, ex ) );
}
}