コード例 #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);
        }
コード例 #7
0
        /// <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();
        }
コード例 #10
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 );
     }
 }
コード例 #11
0
ファイル: ZoneBlocks.ascx.cs プロジェクト: Ganon11/Rock
        /// <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();
        }
コード例 #12
0
        /// <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
ファイル: ZoneBlocks.ascx.cs プロジェクト: NewPointe/Rockit
        /// <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
ファイル: Categories.ascx.cs プロジェクト: pkdevbox/Rock
        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
ファイル: ZoneBlocks.ascx.cs プロジェクト: rowlek/Rock-ChMS
        void gPageBlocks_GridReorder( object sender, GridReorderEventArgs e )
        {
            blockInstanceService.Reorder(
                blockInstanceService.GetByLayoutAndPageIdAndZone( null, _page.Id, _zoneName ).ToList(),
                e.OldIndex, e.NewIndex, CurrentPersonId );

            BindGrids();
        }
コード例 #17
0
ファイル: Grid.cs プロジェクト: tcavaletto/Rock-CentralAZ
        /// <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
ファイル: AccountList.ascx.cs プロジェクト: NewPointe/Rockit
        /// <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
ファイル: Grid.cs プロジェクト: tcavaletto/Rock-CentralAZ
 /// <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
ファイル: MetricDetail.ascx.cs プロジェクト: NewSpring/Rock
 /// <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();
        }
コード例 #23
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 );
     }
 }
コード例 #24
0
ファイル: BatchList.ascx.cs プロジェクト: pkdevbox/Rock
        /// <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();
        }
コード例 #25
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 )
 {
     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();
 }
コード例 #27
0
        /// <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
ファイル: Security.ascx.cs プロジェクト: jh2mhs8/Rock-ChMS
        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();
 }
コード例 #30
0
        /// <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
ファイル: Pages.ascx.cs プロジェクト: rowlek/Rock-ChMS
        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();
        }
コード例 #37
0
        /// <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();
        }
コード例 #38
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="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();
        }