/// <summary>
        /// Binds the grid for defined types.
        /// </summary>
        private void gDefinedType_Bind()
        {
            var queryable = new DefinedTypeService().Queryable().Select(a =>
                                                                        new
            {
                a.Id,
                a.Category,
                a.Name,
                a.Description,
                FieldTypeName = a.FieldType.Name
            });

            string categoryFilter = tFilter.GetUserPreference("Category");

            if (!string.IsNullOrWhiteSpace(categoryFilter) && categoryFilter != Rock.Constants.All.Text)
            {
                queryable = queryable.Where(a => a.Category == categoryFilter);
            }

            SortProperty sortProperty = gDefinedType.SortProperty;

            if (sortProperty != null)
            {
                queryable = queryable.Sort(sortProperty);
            }
            else
            {
                queryable = queryable.OrderBy(a => a.Category).ThenBy(a => a.Name);
            }

            gDefinedType.DataSource = queryable.ToList();
            gDefinedType.DataBind();
        }
Beispiel #2
0
        /// <summary>
        /// Binds the grid for defined types.
        /// </summary>
        private void rGridType_Bind()
        {
            var queryable = new DefinedTypeService().Queryable().
                            Where(a => a.Category != "" && a.Category != null);

            if (ddlCategoryFilter.SelectedValue != "[All]")
            {
                queryable = queryable.
                            Where(a => a.Category == ddlCategoryFilter.SelectedValue);
            }

            SortProperty sortProperty = rGridType.SortProperty;

            if (sortProperty != null)
            {
                queryable = queryable.
                            Sort(sortProperty);
            }
            else
            {
                queryable = queryable.
                            OrderBy(a => a.Category);
            }

            rGridType.DataSource = queryable.ToList();
            rGridType.DataBind();
        }
Beispiel #3
0
        /// <summary>
        /// Binds the grid for defined types.
        /// </summary>
        private void gDefinedType_Bind()
        {
            var queryable = new DefinedTypeService(new RockContext()).Queryable();

            if (_categoryGuids.Any())
            {
                queryable = queryable.Where(a => a.Category != null && _categoryGuids.Contains(a.Category.Guid));
            }
            else
            {
                int?categoryId = tFilter.GetUserPreference("Category").AsIntegerOrNull();
                if (categoryId.HasValue)
                {
                    queryable = queryable.Where(a => a.CategoryId.HasValue && a.CategoryId.Value == categoryId.Value);
                }
            }

            SortProperty sortProperty = gDefinedType.SortProperty;

            if (sortProperty != null)
            {
                queryable = queryable.Sort(sortProperty);
            }
            else
            {
                queryable = queryable.OrderBy(a => a.Category.Name).ThenBy(a => a.Name);
            }

            gDefinedType.DataSource = queryable
                                      .Select(a =>
                                              new
            {
                a.Id,
                Category = a.Category.Name,
                a.Name,
                a.Description,
                a.IsSystem,
                FieldTypeName = a.FieldType.Name
            })
                                      .ToList();

            // SanitizeHtml can't be compilied into a SQL query so we have to ToList() the data and then sanitize the field in the List<T>
            //gDefinedType.DataSource = dataSource
            //    .Select( a =>
            //        new
            //        {
            //            a.Id,
            //            a.Category,
            //            a.Name,
            //            Description = a.Description.ScrubHtmlForGridDisplay(),
            //            a.IsSystem,
            //            a.FieldTypeName
            //        } )
            //    .ToList();
            gDefinedType.DataBind();
        }
        /// <summary>
        /// Binds the grid for defined types.
        /// </summary>
        private void gDefinedType_Bind()
        {
            var queryable = new DefinedTypeService(new RockContext()).Queryable();

            if (_categoryGuids.Any())
            {
                queryable = queryable.Where(a => a.Category != null && _categoryGuids.Contains(a.Category.Guid));
            }
            else
            {
                int?categoryId = tFilter.GetUserPreference("Category").AsIntegerOrNull();
                if (categoryId.HasValue)
                {
                    queryable = queryable.Where(a => a.CategoryId.HasValue && a.CategoryId.Value == categoryId.Value);
                }
            }

            SortProperty sortProperty = gDefinedType.SortProperty;

            if (sortProperty != null)
            {
                queryable = queryable.Sort(sortProperty);
            }
            else
            {
                queryable = queryable.OrderBy(a => a.Category.Name).ThenBy(a => a.Name);
            }

            gDefinedType.DataSource = queryable
                                      .Select(a =>
                                              new
            {
                a.Id,
                Category = a.Category.Name,
                a.Name,
                a.Description,
                a.IsSystem,
                FieldTypeName = a.FieldType.Name
            })
                                      .ToList();
            gDefinedType.DataBind();
        }