当前位置: 首页>>代码示例>>C#>>正文


C# FilterField.SetCheckBoxChecked方法代码示例

本文整理汇总了C#中Rock.Web.UI.Controls.FilterField.SetCheckBoxChecked方法的典型用法代码示例。如果您正苦于以下问题:C# FilterField.SetCheckBoxChecked方法的具体用法?C# FilterField.SetCheckBoxChecked怎么用?C# FilterField.SetCheckBoxChecked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rock.Web.UI.Controls.FilterField的用法示例。


在下文中一共展示了FilterField.SetCheckBoxChecked方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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 );
                                }
//.........这里部分代码省略.........
开发者ID:RMRDevelopment,项目名称:Rockit,代码行数:101,代码来源:DynamicReport.ascx.cs


注:本文中的Rock.Web.UI.Controls.FilterField.SetCheckBoxChecked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。