Exemple #1
0
        protected void RadGrid_WebMedia_RowDrop(object sender, GridDragDropEventArgs e)
        {
            if (e.DestDataItem != null &&
                string.IsNullOrEmpty(e.HtmlElement) &&
                e.DestDataItem.OwnerGridID == RadGrid_WebMedia.ClientID)
            {
                ProductMgr myProductMgr = new ProductMgr();

                List <WebMedia> myWebMedia = myProductMgr.Get_WebMedia(_productid);

                WebMedia draggedAttributeIndex = Get_WebMedia_in_List(myWebMedia, e.DraggedItems[0].GetDataKeyValue("WebMediaID").ToString());
                WebMedia destAttributeIndex    = Get_WebMedia_in_List(myWebMedia, e.DestDataItem.GetDataKeyValue("WebMediaID").ToString());

                int destIndex = myWebMedia.IndexOf(destAttributeIndex);

                if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex)
                {
                    destIndex -= 1;
                }
                if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex)
                {
                    destIndex += 1;
                }

                myWebMedia.Remove(draggedAttributeIndex);
                myWebMedia.Insert(destIndex, draggedAttributeIndex);

                foreach (WebMedia WebMedium in myWebMedia)
                {
                    // Product Variant
                    e2Data[] UpdateData =
                    {
                        new e2Data("WebMediaID", WebMedium.WebMediaID),
                        new e2Data("SortOrder",  (myWebMedia.IndexOf(Get_WebMedia_in_List(myWebMedia, WebMedium.WebMediaID)) + 1).ToString())
                    };

                    myProductMgr.Edit_WebMedia(UpdateData);
                }

                RadGrid_WebMedia.Rebind();
            }
        }
Exemple #2
0
        private void Control_Init()
        {
            RadGrid_WebMedia.Rebind();

            MultiView_WebMediaForm.SetActiveView(View_Button);
        }