本文整理汇总了C#中Rock.Web.UI.Controls.FilterField.RockBlock方法的典型用法代码示例。如果您正苦于以下问题:C# FilterField.RockBlock方法的具体用法?C# FilterField.RockBlock怎么用?C# FilterField.RockBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Web.UI.Controls.FilterField
的用法示例。
在下文中一共展示了FilterField.RockBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateChildControls
/// <summary>
/// Creates the child controls.
/// </summary>
/// <returns></returns>
public override Control[] CreateChildControls( Type entityType, FilterField filterControl, FilterMode filterMode )
{
var containerControl = new DynamicControlsPanel();
containerControl.ID = string.Format( "{0}_containerControl", filterControl.ID );
containerControl.CssClass = "js-container-control";
filterControl.Controls.Add( containerControl );
// Create the field selection dropdown
var ddlEntityField = new RockDropDownList();
ddlEntityField.ID = string.Format( "{0}_ddlProperty", filterControl.ID );
ddlEntityField.ClientIDMode = ClientIDMode.Predictable;
containerControl.Controls.Add( ddlEntityField );
// add Empty option first
ddlEntityField.Items.Add( new ListItem() );
var rockBlock = filterControl.RockBlock();
var entityTypeCache = EntityTypeCache.Read( entityType, true );
this.entityFields = EntityHelper.GetEntityFields( entityType );
foreach ( var entityField in this.entityFields.OrderBy(a => !a.IsPreviewable).ThenBy(a => a.FieldKind != FieldKind.Property ).ThenBy(a => a.Title) )
{
bool isAuthorized = true;
bool includeField = true;
if ( entityField.FieldKind == FieldKind.Attribute && entityField.AttributeGuid.HasValue)
{
if ( entityType == typeof( Rock.Model.Workflow ) && !string.IsNullOrWhiteSpace(entityField.AttributeEntityTypeQualifierName) )
{
// Workflows can contain tons of Qualified Attributes, so let the WorkflowAttributeFilter take care of those
includeField = false;
}
var attribute = AttributeCache.Read( entityField.AttributeGuid.Value );
if ( includeField && attribute != null && rockBlock != null )
{
// only show the Attribute field in the drop down if they have VIEW Auth to it
isAuthorized = attribute.IsAuthorized( Rock.Security.Authorization.VIEW, rockBlock.CurrentPerson );
}
}
if ( isAuthorized && includeField )
{
var listItem = new ListItem( entityField.Title, entityField.Name );
if ( entityField.IsPreviewable )
{
listItem.Attributes["optiongroup"] = "Common";
}
else if (entityField.FieldKind == FieldKind.Attribute)
{
listItem.Attributes["optiongroup"] = string.Format( "{0} Attributes", entityType.Name );
}
else
{
listItem.Attributes["optiongroup"] = string.Format( "{0} Fields", entityType.Name );
}
ddlEntityField.Items.Add( listItem );
}
}
ddlEntityField.AutoPostBack = true;
// grab the currently selected value off of the request params since we are creating the controls after the Page Init
var selectedValue = ddlEntityField.Page.Request.Params[ddlEntityField.UniqueID];
if ( selectedValue != null )
{
ddlEntityField.SelectedValue = selectedValue;
ddlEntityField_SelectedIndexChanged( ddlEntityField, new EventArgs() );
}
ddlEntityField.SelectedIndexChanged += ddlEntityField_SelectedIndexChanged;
return new Control[] { containerControl };
}
示例2: RegisterJavascriptInclude
/// <summary>
/// Registers the javascript include needed for reporting client controls
/// </summary>
/// <param name="filterField">The filter field.</param>
public static void RegisterJavascriptInclude( FilterField filterField )
{
ScriptManager.RegisterClientScriptInclude( filterField, filterField.GetType(), "reporting-include", filterField.RockBlock().RockPage.ResolveRockUrl( "~/Scripts/Rock/reportingInclude.js", true ) );
}