/// <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); } }
protected void checkinGroup_ReorderLocationClick( object sender, CheckinGroupEventArg e ) { // First set the order (indexing from 0)... since initially all locations will have an // order of 0, we'll also order by their 'full name path' int order = 0; foreach ( var location in checkinGroup.Locations.OrderBy( l => l.Order ).ThenBy( l => l.FullNamePath ) ) { location.Order = order++; } var movedItem = checkinGroup.Locations.FirstOrDefault( a => a.LocationId == e.LocationId ); if ( movedItem != null ) { if ( e.NewIndex < e.OldIndex ) { // Moved up foreach ( var otherItem in checkinGroup.Locations.Where( a => a.Order < e.OldIndex && a.Order >= e.NewIndex ) ) { otherItem.Order = otherItem.Order + 1; } } else { // Moved Down foreach ( var otherItem in checkinGroup.Locations.Where( a => a.Order > e.OldIndex && a.Order <= e.NewIndex ) ) { otherItem.Order = otherItem.Order - 1; } } movedItem.Order = e.NewIndex; hfIsDirty.Value = "true"; } }
/// <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 ); } }