Example #1
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            RockDropDownList ddlSignalType = new RockDropDownList();

            ddlSignalType.ID       = filterControl.ID + "_ddlSignalType";
            ddlSignalType.CssClass = "js-signal-type-list";
            ddlSignalType.Label    = "Signal Type";
            filterControl.Controls.Add(ddlSignalType);

            var signalTypeService  = new SignalTypeService(new RockContext());
            var entityTypeIdPerson = EntityTypeCache.GetId <Rock.Model.Person>();
            var signalTypes        = signalTypeService.Queryable()
                                     .OrderBy(a => a.Order)
                                     .ThenBy(a => a.Name)
                                     .Select(a => new
            {
                a.Id,
                a.Name
            }).ToList();

            ddlSignalType.Items.Clear();
            ddlSignalType.Items.Add(new ListItem());
            ddlSignalType.Items.AddRange(signalTypes.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray());

            return(new System.Web.UI.Control[] { ddlSignalType });
        }
        /// <summary>
        /// Handles the GridReorder event of the gPersonSignalType control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs" /> instance containing the event data.</param>
        void gPersonSignalType_GridReorder(object sender, GridReorderEventArgs e)
        {
            var rockContext = new RockContext();
            var service     = new SignalTypeService(rockContext);
            var signalTypes = service.Queryable().OrderBy(b => b.Order);

            service.Reorder(signalTypes.ToList(), e.OldIndex, e.NewIndex);
            rockContext.SaveChanges();

            BindGrid();
        }