Пример #1
0
 /// <summary>
 /// Raises the <see cref="E:GridReorder"/> event.
 /// </summary>
 /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
 protected virtual void OnGridReorder(GridReorderEventArgs e)
 {
     if (GridReorder != null)
     {
         GridReorder(this, e);
     }
 }
Пример #2
0
        /// <summary>
        /// Raises the appropriate events for the <see cref="T:System.Web.UI.WebControls.GridView"/> control when it posts back to the server.
        /// </summary>
        /// <param name="eventArgument">The event argument from which to create a <see cref="T:System.Web.UI.WebControls.CommandEventArgs"/> for the event or events that are raised.</param>
        void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
        {
            if (eventArgument.StartsWith("re-order:"))
            {
                string[] parms = eventArgument.Substring(9).Split(';');

                string dataKey = parms[0];

                int oldIndex = 0;
                if (!Int32.TryParse(parms[1], out oldIndex))
                {
                    oldIndex = 0;
                }

                int newIndex = 0;
                if (!Int32.TryParse(parms[2], out newIndex))
                {
                    newIndex = 0;
                }

                int pageFactor = this.PageIndex * this.PageSize;
                oldIndex += pageFactor;
                newIndex += pageFactor;

                GridReorderEventArgs args = new GridReorderEventArgs(dataKey, oldIndex, newIndex);
                OnGridReorder(args);
            }
            else
            {
                base.RaisePostBackEvent(eventArgument);
            }
        }
Пример #3
0
 /// <summary>
 /// Handles the Reorder event of the gLocations control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
 protected void gLocations_Reorder(object sender, GridReorderEventArgs e)
 {
     if (ReorderLocationClick != null)
     {
         var eventArg = new CheckinGroupEventArg(GroupGuid, e.DataKey, e.OldIndex, e.NewIndex);
         ReorderLocationClick(this, eventArg);
     }
 }
Пример #4
0
 /// <summary>
 /// Handles the Reorder event of the gFields control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
 protected void gFields_Reorder(object sender, GridReorderEventArgs e)
 {
     if (ReorderFieldClick != null)
     {
         var eventArg = new TemplateFormFieldEventArg(FormGuid, e.OldIndex, e.NewIndex);
         ReorderFieldClick(this, eventArg);
     }
 }
Пример #5
0
 /// <summary>
 /// Handles the Reorder event of the gAttributes control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
 protected void gAttributes_Reorder(object sender, GridReorderEventArgs e)
 {
     if (ReorderAttributeClick != null)
     {
         var eventArg = new WorkflowActivityTypeAttributeEventArg(ActivityTypeGuid, e.OldIndex, e.NewIndex);
         ReorderAttributeClick(this, eventArg);
     }
 }
Пример #6
0
        /// <summary>
        /// Handles the GridReorder event of the gMatrixItems control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void gMatrixItems_GridReorder(object sender, GridReorderEventArgs e)
        {
            var rockContext     = new RockContext();
            var attributeMatrix = new AttributeMatrixService(rockContext).Get(this.AttributeMatrixGuid.Value);
            var service         = new AttributeMatrixItemService(rockContext);
            var items           = service.Queryable().Where(a => a.AttributeMatrixId == attributeMatrix.Id).OrderBy(i => i.Order).ToList();

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

            BindGrid(this.AttributeMatrixGuid);
        }
        /// <summary>
        /// Handles the GridReorder event of the gContentChannelItems control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gContentChannelItems_GridReorder(object sender, Rock.Web.UI.Controls.GridReorderEventArgs e)
        {
            var contentChannel = this.GetContentChannel();

            if (contentChannel != null)
            {
                var rockContext = new RockContext();
                ContentChannelItemService contentChannelItemService = new ContentChannelItemService(rockContext);
                var contentChannelItems = contentChannelItemService.Queryable().Where(a => a.ContentChannelId == contentChannel.Id).OrderBy(a => a.Order).ThenBy(a => a.Title).ToList();
                contentChannelItemService.Reorder(contentChannelItems, e.OldIndex, e.NewIndex);
                rockContext.SaveChanges();
                BindContentChannelItemsGrid();
            }
        }
Пример #8
0
        /// <summary>
        /// Handles the GridReorder event of the gPages control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gPages_GridReorder(object sender, Rock.Web.UI.Controls.GridReorderEventArgs e)
        {
            var applicationId = PageParameter(PageParameterKey.SiteId).AsInteger();

            using (var rockContext = new RockContext())
            {
                PageService pageService = new PageService(rockContext);
                var         pages       = pageService.GetBySiteId(applicationId)
                                          .OrderBy(p => p.Order)
                                          .ThenBy(p => p.InternalName)
                                          .ToList();
                pageService.Reorder(pages, e.OldIndex, e.NewIndex);
                rockContext.SaveChanges();
            }

            BindPages( );
        }
Пример #9
0
        /// <summary>
        /// Handles the GridReorder event of the rGridSuggestion 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 rGridSuggestion_GridReorder( object sender, GridReorderEventArgs e )
        {
            var rockContext = new RockContext();
            var service = new FollowingSuggestionTypeService( rockContext );
            var followingSuggestions = service.Queryable().OrderBy( i => i.Order ).ToList();
            service.Reorder( followingSuggestions, e.OldIndex, e.NewIndex );
            rockContext.SaveChanges();

            BindGrid();
        }
 /// <summary>
 /// Handles the Reorder event of the gFields control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
 protected void gFields_Reorder( object sender, GridReorderEventArgs e )
 {
     if ( ReorderFieldClick != null )
     {
         var eventArg = new TemplateFormFieldEventArg( FormGuid, e.OldIndex, e.NewIndex );
         ReorderFieldClick( this, eventArg );
     }
 }
Пример #11
0
        /// <summary>
        /// Handles the GridReorder event of the gPageBlocks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gPageBlocks_GridReorder( object sender, GridReorderEventArgs e )
        {
            int pageId = PageParameter( "EditPage" ).AsInteger();
            Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId );
            string zoneName = this.PageParameter( "ZoneName" );

            var rockContext = new RockContext();
            BlockService blockService = new BlockService( rockContext );
            var blocks = blockService.GetByPageAndZone( page.Id, zoneName ).ToList();
            blockService.Reorder( blocks, e.OldIndex, e.NewIndex );
            rockContext.SaveChanges();
            page.FlushBlocks();

            BindGrids();
        }
        /// <summary>
        /// Handles the GridReorder event of the gFees control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gFees_GridReorder( object sender, GridReorderEventArgs e )
        {
            ParseControls();

            var movedItem = FeeState.Where( a => a.Order == e.OldIndex ).FirstOrDefault();
            if ( movedItem != null )
            {
                if ( e.NewIndex < e.OldIndex )
                {
                    // Moved up
                    foreach ( var otherItem in FeeState.Where( a => a.Order < e.OldIndex && a.Order >= e.NewIndex ) )
                    {
                        otherItem.Order = otherItem.Order + 1;
                    }
                }
                else
                {
                    // Moved Down
                    foreach ( var otherItem in FeeState.Where( a => a.Order > e.OldIndex && a.Order <= e.NewIndex ) )
                    {
                        otherItem.Order = otherItem.Order - 1;
                    }
                }

                movedItem.Order = e.NewIndex;
            }

            int order = 0;
            FeeState.OrderBy( f => f.Order ).ToList().ForEach( f => f.Order = order++ );

            BuildControls();
        }
Пример #13
0
        /// <summary>
        /// Handles the GridReorder event of the gAttributes control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gAttributes_GridReorder( object sender, GridReorderEventArgs e )
        {
            ParseControls();

            SortAttributes( AttributesState, e.OldIndex, e.NewIndex );
            ReOrderAttributes( AttributesState );
            BindAttributesGrid();
            BuildControls( true );
        }
Пример #14
0
        /// <summary>
        /// Handles the GridReorder event of the gPageBlocks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gPageBlocks_GridReorder( object sender, GridReorderEventArgs e )
        {
            using ( var rockContext = new RockContext() )
            {
                BlockService blockService = new BlockService( rockContext );
                var blocks = blockService.GetByPageAndZone( _Page.Id, _ZoneName ).ToList();
                blockService.Reorder( blocks, e.OldIndex, e.NewIndex );
                rockContext.SaveChanges();
            }

            _Page.FlushBlocks();
            PageUpdated = true;

            BindGrids();
        }
Пример #15
0
        void gCategories_GridReorder( object sender, GridReorderEventArgs e )
        {
            using ( new UnitOfWorkScope() )
            {
                var categories = GetCategories();
                if ( categories != null )
                {
                    new CategoryService().Reorder( categories.ToList(), e.OldIndex, e.NewIndex, CurrentPersonId );
                }

                BindGrid();
            }
        }
Пример #16
0
        void gPageBlocks_GridReorder( object sender, GridReorderEventArgs e )
        {
            blockInstanceService.Reorder(
                blockInstanceService.GetByLayoutAndPageIdAndZone( null, _page.Id, _zoneName ).ToList(),
                e.OldIndex, e.NewIndex, CurrentPersonId );

            BindGrids();
        }
Пример #17
0
        /// <summary>
        /// Raises the appropriate events for the <see cref="T:System.Web.UI.WebControls.GridView"/> control when it posts back to the server.
        /// </summary>
        /// <param name="eventArgument">The event argument from which to create a <see cref="T:System.Web.UI.WebControls.CommandEventArgs"/> for the event or events that are raised.</param>
        void IPostBackEventHandler.RaisePostBackEvent( string eventArgument )
        {
            if ( eventArgument.StartsWith( "re-order:" ) )
            {
                string[] parms = eventArgument.Substring( 9 ).Split( ';' );

                string dataKey = parms[0];

                int oldIndex = 0;
                if ( !int.TryParse( parms[1], out oldIndex ) )
                {
                    oldIndex = 0;
                }

                int newIndex = 0;
                if ( !int.TryParse( parms[2], out newIndex ) )
                {
                    newIndex = 0;
                }

                int pageFactor = this.PageIndex * this.PageSize;
                oldIndex += pageFactor;
                newIndex += pageFactor;

                GridReorderEventArgs args = new GridReorderEventArgs( dataKey, oldIndex, newIndex );
                OnGridReorder( args );
            }
            else
            {
                base.RaisePostBackEvent( eventArgument );
            }
        }
Пример #18
0
        /// <summary>
        /// Handles the GridReorder event of the rGridAccounts control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void rGridAccount_GridReorder( object sender, GridReorderEventArgs e )
        {
            var rockContext = new RockContext();
            var accounts = GetAccounts( rockContext );
            if ( accounts != null )
            {
                new FinancialAccountService( rockContext ).Reorder( accounts.ToList(), e.OldIndex, e.NewIndex );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Пример #19
0
 /// <summary>
 /// Raises the <see cref="E:GridReorder"/> event.
 /// </summary>
 /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
 protected virtual void OnGridReorder( GridReorderEventArgs e )
 {
     if ( GridReorder != null )
     {
         GridReorder( this, e );
     }
 }
Пример #20
0
        /// <summary>
        /// Handles the GridReorder event of the rGrid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void rGrid_GridReorder( object sender, GridReorderEventArgs e )
        {
            int entityTypeId = iSecured.TypeId;

            var rockContext = new RockContext();
            var authService = new Rock.Model.AuthService( rockContext );
            List<Rock.Model.Auth> rules = authService.GetAuths( iSecured.TypeId, iSecured.Id, CurrentAction ).ToList();
            authService.Reorder( rules, e.OldIndex, e.NewIndex );
            rockContext.SaveChanges();

            Authorization.ReloadAction( iSecured.TypeId, iSecured.Id, CurrentAction );

            BindGrid();
        }
Пример #21
0
 /// <summary>
 /// Handles the GridReorder event of the gMetricPartitions control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
 protected void gMetricPartitions_GridReorder( object sender, GridReorderEventArgs e )
 {
     ReorderMetricPartitionsList( MetricPartitionsState, e.OldIndex, e.NewIndex );
     BindMetricPartitionsGrid();
 }
Пример #22
0
        /// <summary>
        /// Handles the GridReorder event of the rGrid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void rGrid_GridReorder( object sender, GridReorderEventArgs e )
        {
            var categories = GetCategories();
            if ( categories != null )
            {
                var rockContext = new RockContext();
                new CategoryService( rockContext ).Reorder( categories.ToList(), e.OldIndex, e.NewIndex );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
 /// <summary>
 /// Handles the Reorder event of the gAttributes control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
 protected void gAttributes_Reorder( object sender, GridReorderEventArgs e )
 {
     if ( ReorderAttributeClick != null )
     {
         var eventArg = new WorkflowActivityTypeAttributeEventArg( ActivityTypeGuid, e.OldIndex, e.NewIndex );
         ReorderAttributeClick( this, eventArg );
     }
 }
Пример #24
0
        /// <summary>
        /// Handles the GridReorder event of the grdFinancialBatch control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void rGridBatch_GridReorder( object sender, GridReorderEventArgs e )
        {
            var batchService = new Rock.Model.FinancialBatchService();
            var queryable = batchService.Queryable();

            List<Rock.Model.FinancialBatch> items = queryable.ToList();
            batchService.Reorder( items, e.OldIndex, e.NewIndex, CurrentPersonId );
            BindGrid();
        }
 /// <summary>
 /// Handles the GridReorder event of the gAttributes control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
 protected void gAttributes_GridReorder( object sender, GridReorderEventArgs e )
 {
     ReorderAttributeList( AttributesState, e.OldIndex, e.NewIndex );
     BindAttributesGrid();
 }
 /// <summary>
 /// Handles the GridReorder event of the gGroupTypeRoles control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
 protected void gGroupTypeRoles_GridReorder( object sender, GridReorderEventArgs e )
 {
     ReorderGroupTypeRoleList( GroupTypeRolesState, e.OldIndex, e.NewIndex );
     BindGroupTypeRolesGrid();
 }
        /// <summary>
        /// Handles the GridReorder event of the gItemAttributes control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gItemAttributes_GridReorder( object sender, GridReorderEventArgs e )
        {
            var movedItem = ItemAttributesState.Where( a => a.Order == e.OldIndex ).FirstOrDefault();
            if ( movedItem != null )
            {
                if ( e.NewIndex < e.OldIndex )
                {
                    // Moved up
                    foreach ( var otherItem in ItemAttributesState.Where( a => a.Order < e.OldIndex && a.Order >= e.NewIndex ) )
                    {
                        otherItem.Order = otherItem.Order + 1;
                    }
                }
                else
                {
                    // Moved Down
                    foreach ( var otherItem in ItemAttributesState.Where( a => a.Order > e.OldIndex && a.Order <= e.NewIndex ) )
                    {
                        otherItem.Order = otherItem.Order - 1;
                    }
                }

                movedItem.Order = e.NewIndex;
            }

            BindItemAttributesGrid();
        }
Пример #28
0
        void rGrid_GridReorder( object sender, GridReorderEventArgs e )
        {
            int entityTypeId = iSecured.TypeId;

            List<Rock.Model.Auth> rules = authService.GetAuths( iSecured.TypeId, iSecured.Id, CurrentAction ).ToList();
            authService.Reorder( rules, e.OldIndex, e.NewIndex, CurrentPersonId );

            Authorization.ReloadAction( iSecured.TypeId, iSecured.Id, CurrentAction );

            BindGrid();
        }
Пример #29
0
 /// <summary>
 /// Handles the GridReorder event of the gMemberWorkflowTriggers control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
 protected void gMemberWorkflowTriggers_GridReorder( object sender, GridReorderEventArgs e )
 {
     ReorderMemberWorkflowTriggerList( MemberWorkflowTriggersState, e.OldIndex, e.NewIndex );
     BindMemberWorkflowTriggersGrid();
 }
        /// <summary>
        /// Handles the GridReorder event of the gFields control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gFields_GridReorder( object sender, GridReorderEventArgs e )
        {
            ParseControls();

            if ( FormFieldsState.Any() )
            {
                var keyValue = FormFieldsState.First();
                SortFields( keyValue.Value, e.OldIndex, e.NewIndex );
                ReOrderFields( keyValue.Value );
            }

            BuildControls();
        }
Пример #31
0
 private void gWidgityItemAttributes_GridReorder(object sender, Rock.Web.UI.Controls.GridReorderEventArgs e)
 {
     WidgityItemAttributes = SortAttributes(WidgityItemAttributes, e.OldIndex, e.NewIndex);
     SaveState();
 }
Пример #32
0
        /// <summary>
        /// Handles the GridReorder event of the gDefinedValues control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void gDefinedValues_GridReorder( object sender, GridReorderEventArgs e )
        {
            int definedTypeId = hfDefinedTypeId.ValueAsInt();
            DefinedTypeCache.Flush( definedTypeId );

            using ( new UnitOfWorkScope() )
            {
                var definedValueService = new DefinedValueService();               
                var definedValues = definedValueService.Queryable().Where( a => a.DefinedTypeId == definedTypeId ).OrderBy( a => a.Order );
                definedValueService.Reorder( definedValues.ToList(), e.OldIndex, e.NewIndex, CurrentPersonId );
                BindDefinedValuesGrid();
            }
        }
Пример #33
0
        /// <summary>
        /// Handles the GridReorder event of the gGroupType control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gGroupType_GridReorder( object sender, GridReorderEventArgs e )
        {
            var rockContext = new RockContext();

            var groupTypes = GetGroupTypes( rockContext );
            if ( groupTypes != null )
            {
                new GroupTypeService( rockContext ).Reorder( groupTypes.ToList(), e.OldIndex, e.NewIndex );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Пример #34
0
        /// <summary>
        /// Handles the GridReorder event of the rGrid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void rGrid_GridReorder( object sender, GridReorderEventArgs e )
        {
            var tags = GetTags();
            if ( tags != null )
            {
                var rockContext = new RockContext();
                var tagService = new TagService( rockContext );
                tagService.Reorder( tags.ToList(), e.OldIndex, e.NewIndex );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Пример #35
0
        /// <summary>
        /// Handles the GridReorder event of the gBatchList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void gBatchList_GridReorder( object sender, GridReorderEventArgs e )
        {
            var rockContext = new RockContext();
            var batchService = new Rock.Model.FinancialBatchService( rockContext );
            var queryable = batchService.Queryable();

            List<Rock.Model.FinancialBatch> items = queryable.ToList();
            batchService.Reorder( items, e.OldIndex, e.NewIndex );
            rockContext.SaveChanges();
            BindGrid();
        }
Пример #36
0
        void rGrid_GridReorder( object sender, GridReorderEventArgs e )
        {
            int? parentPageId = null;
            if (_page != null)
                parentPageId = _page.Id;

            pageService.Reorder( pageService.GetByParentPageId( parentPageId ).ToList(),
                e.OldIndex, e.NewIndex, CurrentPersonId );

            BindGrid();
        }
        /// <summary>
        /// Handles the GridReorder event of the gDefinedTypeAttributes 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 gDefinedTypeAttributes_GridReorder( object sender, GridReorderEventArgs e )
        {
            string qualifierValue = hfDefinedTypeId.Value;

            var rockContext = new RockContext();
            var attributeService = new AttributeService( rockContext );

            int order = 0;
            var attributes = attributeService
                .GetByEntityTypeId( new DefinedValue().TypeId ).AsQueryable()
                .Where( a =>
                    a.EntityTypeQualifierColumn.Equals( "DefinedTypeId", StringComparison.OrdinalIgnoreCase ) &&
                    a.EntityTypeQualifierValue.Equals( qualifierValue ) )
                .OrderBy( a => a.Order )
                .ThenBy( a => a.Name )
                .ToList();

            attributes.ForEach( a => a.Order = order++ );

            var movedItem = attributes.Where( a => a.Order == e.OldIndex ).FirstOrDefault();
            if ( movedItem != null )
            {
                if ( e.NewIndex < e.OldIndex )
                {
                    // Moved up
                    foreach ( var otherItem in attributes.Where( a => a.Order < e.OldIndex && a.Order >= e.NewIndex ) )
                    {
                        otherItem.Order = otherItem.Order + 1;
                    }
                }
                else
                {
                    // Moved Down
                    foreach ( var otherItem in attributes.Where( a => a.Order > e.OldIndex && a.Order <= e.NewIndex ) )
                    {
                        otherItem.Order = otherItem.Order - 1;
                    }
                }

                movedItem.Order = e.NewIndex;
                rockContext.SaveChanges();
            }

            BindDefinedTypeAttributesGrid();
        }
        /// <summary>
        /// Handles the GridReorder event of the rGrid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Controls.GridReorderEventArgs"/> instance containing the event data.</param>
        void rGrid_GridReorder( object sender, GridReorderEventArgs e )
        {
            var components = _container.Dictionary.ToList();
            var movedItem = components[e.OldIndex];
            components.RemoveAt( e.OldIndex );
            if ( e.NewIndex >= components.Count )
                components.Add( movedItem );
            else
                components.Insert( e.NewIndex, movedItem );

            var rockContext = new RockContext();
            int order = 0;
            foreach ( var item in components )
            {
                Component component = item.Value.Value;
                if (  component.Attributes.ContainsKey("Order") )
                {
                    Rock.Attribute.Helper.SaveAttributeValue( component, component.Attributes["Order"], order.ToString(), rockContext );
                }
                order++;
            }

            _container.Refresh();

            BindGrid();
        }
Пример #39
0
        void gCategories_GridReorder( object sender, GridReorderEventArgs e )
        {
            var rockContext = new RockContext();
            var categories = GetCategories( rockContext );
            if ( categories != null )
            {
                var changedIds = new CategoryService( rockContext ).Reorder( categories.ToList(), e.OldIndex, e.NewIndex );
                rockContext.SaveChanges();

                foreach ( int id in changedIds )
                {
                    CategoryCache.Flush( id );
                }
            }

            BindGrid();
        }