This is a migrated thread and some comments may be shown as answers.

How to drag and drop rows between 2 GridViews

16 Answers 352 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brian Chung
Top achievements
Rank 1
Brian Chung asked on 29 Mar 2010, 11:38 AM
Hello,

I am a newbie with Silverlight and now doing a prototype with Teletrik controls for evaluation.
My objective is to drag and drop rows between 2 gridviews.
I know there is  a "dragdroptarget" control on the original Silverlight API to support datagrid drag and drop but I wonder what are the advantages of telerik controls over the original one. Can it shorten my development time?

Here is what I have done.
1) I construct 2 gridviews and fake data to 1 gridview

2) Prepare the drag and drop event

                <telerikGridView:RadGridView x:Name="RadGridView1" Foreground="Black" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" Margin="-422,34,0,359" AlternateRowBackground="#FFB3B38D" 
                    dragDrop:RadDragAndDropManager.AllowDrag="True"  HorizontalAlignment="Left" Width="741"    
                    RowStyle="{StaticResource ProductStyle}"      
                        > 
 
            ...  
              
                <telerikGridView:RadGridView x:Name="RadGridView2" Foreground="#FF020202" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" Height="296" Margin="-425,0,0,33" BorderThickness="2,2,1,1" VerticalAlignment="Bottom" AlternateRowBackground="#FFB38C55"   
                    dragDrop:RadDragAndDropManager.AllowDrop="True" HorizontalAlignment="Left" Width="828" 
                    RowStyle="{StaticResource ProductStyle1}"  CanUserInsertRows="True"   
                    > 

 

            RadDragAndDropManager.AddDragQueryHandler(RadGridView1, OnGV1DragQuery);  
            RadDragAndDropManager.AddDragInfoHandler (RadGridView1, OnGV1DragInfo);  
 
            RadDragAndDropManager.AddDropQueryHandler(RadGridView2, OnGV2DropQuery);  
            RadDragAndDropManager.AddDropInfoHandler(RadGridView2, OnGV2DropInfo);  
 
 
..  
 
        private void OnGV1DragQuery(object sender, DragDropQueryEventArgs e)  
        {  
            RadGridView gridView = sender as RadGridView;  
            if (gridView != null)  
            {  
                IList selectedItems = gridView.SelectedItems.ToList();  
                e.QueryResult = selectedItems.Count > 0;  
                e.Options.Payload = selectedItems;  
            }  
            e.Options.DragCue = "I AM BEING DRAGGING...";  
            e.QueryResult = true;  
            e.Handled = true;  
        }  
 
 
        private void OnGV1DragInfo(object sender, DragDropEventArgs e)  
        {  
            RadGridView gridView = sender as RadGridView;  
            IEnumerable draggedItems = e.Options.Payload as IEnumerable;  
 
            if (e.Options.Status == DragStatus.DragInProgress)  
            {  
                //Set up a drag cue:  
                TreeViewDragCue cue = new TreeViewDragCue();  
                //Here we need to choose a template for the items:  
                cue.ItemTemplate = this.Resources["ProductTemplate"as DataTemplate;  
                cue.ItemsSource = draggedItems;  
                e.Options.DragCue = cue;  
            }  
            else if (e.Options.Status == DragStatus.DragComplete)  
            {  
                IList source = gridView.ItemsSource as IList;  
                foreach (object draggedItem in draggedItems)  
                {  
                    source.Remove(draggedItem);  
                }  
            }  
        }  
 
 
 
 
        private void OnGV2DropQuery(object sender, DragDropQueryEventArgs e)  
        {  
            // We allow drop only if the dragged items are products:  
            ICollection draggedItems = e.Options.Payload as ICollection;  
            bool result = draggedItems.Cast<object>().All((object item) => item is Product_Global_Line);  
            e.QueryResult = result;  
            e.Handled = true;  
 
            // Note that here we agree to accept a drop. We will be notified  
            // in the DropInfo event whether a drop is actually possible.  
 
        }  
 
        private void OnGV2DropInfo(object sender, DragDropEventArgs e)  
        {  
 
            RadGridView order = e.Options.Destination as RadGridView;  
            ICollection draggedItems = e.Options.Payload as ICollection;  
 
            // Get the drag cu that the TreeView or we have created  
            TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue;  
 
            if (e.Options.Status == DragStatus.DropPossible)  
            {  
                // Set a suitable text:  
                string newString;  
                newString = String.Format("Add {0}", draggedItems.Count);  
                cue.DragActionContent = newString;  
 
                cue.IsDropPossible = true;  
                order.Background = this.Resources["DropPossibleBackground"as Brush;  
            }  
            else if (e.Options.Status == DragStatus.DropImpossible)  
            {  
                cue.DragActionContent = null;  
                cue.IsDropPossible = false;  
            }  
            else if (e.Options.Status == DragStatus.DropComplete)  
            {  
                IList items = order.ItemsSource as IList;  
                foreach (object draggedItem in draggedItems)  
                {  
                    items.Add(draggedItem);  
                }  
            }  
 
            if (e.Options.Status != DragStatus.DropPossible)  
            {  
                order.Background = new SolidColorBrush(Colors.White);  
            }  
 
 
 
        }  
 

 

 

but it doesn't work. Do you have any idea why? Thank you!

Brian

16 Answers, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 30 Mar 2010, 08:37 AM
Hi Brian Chung,

Based on the code snippets sent I have prepared sample project that allow dragging from one GridView to other.
 Note the following points:

 - When start to drag you add in e.Options.DragCue string (I AM BEING DRAGGING...).
However in OnGV2DropInfo the code expects TreeViewDragCue (TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue).  This cause exception on dragging to the second GridView.
 - If user need to perform grouping the following check is needed in order not to interfere in Header drag and drop:
if (e.Options.Source is GridViewHeaderCell || e.Options.Source is GridViewGroupPanelCell)
   return;

Please check the attached application and let me know if you have any other questions.

Regards,
Tsvyatko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Brian Chung
Top achievements
Rank 1
answered on 30 Mar 2010, 11:28 AM
Thank you, Tsvyatko!
It is what I need and my colleauges are amazed that we can get this quicky. I think your product are so matched with our needs.

Few more question,
1) is it possible to do multiple selection with Drag-and-Drop
2) is it possible to create a GridView-Hierarchy at the same time when the object is being dropped?
 For example, the newly dragged product have different colors (see the attchment)

Thank you!

Brian
0
Tsvyatko
Telerik team
answered on 30 Mar 2010, 01:24 PM
Hello Brian Chung,

I have modified the attached project to be able to perform multiple drag - drop, and building hierarchy on drop. The child table rows are styled in order to change their background. If needed, the logic for their color can be extended using Conditional formatting based on property in the data model that keeps the information whether the row is dropped from external source (by Binding and IValueConverters).

If you have any other questions or issues do not hesitate to contact us.

Greetings,
Tsvyatko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Brian Chung
Top achievements
Rank 1
answered on 31 Mar 2010, 10:40 AM
Hi Tsvyatko,

Thanks for the promptly demostration of your product.

I still have few questions

1) how can you manage formula calculation within the grid? For example, Total = Unit Price * Quantity i.e. forth columns the gridview will depends on the values of first and third column
2) When I dragged the row from  the first gridview to the second one(I clean up all the records within it), It returned me a null reference execption and I don't know how to fix it.
3) In the example, you demostrate a Product Class (ID, Name, Unit Price) with drag and drop between 2 gridviews.
Is it possible to create a new Object e.g. Product_Color Class (<Product>, Color, Description) , inherit from Product Class, in the second gridview when dragging?

GridView1
----------
|Product|
-----------

GirdView2
-----------------------
|Dragged Product|
-----------------------
|Color                |
|Color                |
..
-----------------------

We know Silverlight 4 is coming, I wonder will there be a new release of RadContols coming soon? Will a "early renewal" serves the upgrade purpose? Thank you so much!


Brian
0
Tsvyatko
Telerik team
answered on 01 Apr 2010, 10:10 AM
Hi Brian Chung,

Straight to your questions:

Q - 1) how can you manage formula calculation within the grid? For example, Total = Unit Price * Quantity i.e. forth columns the gridview will depends on the values of first and third column

A - Currently we do not support such scenarios, however we have planned providing such functionality with your Q2 release. Currently this functionality can be achieved by creating custom column that performs this functionality.

Q - 2) When I dragged the row from  the first gridview to the second one(I clean up all the records within it), It returned me a null reference execption and I don't know how to fix it.

A - You can drop in Grid with no items, however it needs its items source (even if it is empty collection) to operate correctly. I have modified the sample project is order to operate correctly.

Q - Is it possible to create a new Object e.g. Product_Color Class (<Product>, Color, Description) , inherit from Product Class, in the second gridview when dragging?.

A - You can create new object from the information in the drag cue. I have modified the project, so that the second grid binds to Product_Color.

Let me know, if you need any further assistance.

Best wishes,
Tsvyatko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Brian Chung
Top achievements
Rank 1
answered on 04 Apr 2010, 07:06 PM
Hello Tsvyatko,

Thanks for the reply. I still have questions

1) It's about column footer that I don't know why it is not working. Any idea? I try the simplest case of COUNT, it doesn't work for me ;(
Actually I want to  implement the SUM and Average function.

2) For building a formula in gridview, if the US_Retail= (US_Whole * 2 + US_FOB *4) / 1.85, how can I implement it into the gridview and refresh the US_Retail when the US_Whole or US_FOB has changed?

Thank you so much and your support it's been very helpful for me to building a prototype with RadControls.
Brian

Here is my coding
<UserControl x:Class="MMXPrototype.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:grid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" 
    xmlns:gridView="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView" 
    xmlns:data="clr-namespace:Telerik.Windows.Data;assembly=Telerik.Windows.Data" 
    xmlns:controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
    xmlns:dragdrop="clr-namespace:Telerik.Windows.Controls.DragDrop;assembly=Telerik.Windows.Controls" 
    xmlns:Navigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" Width="1024" Height="768"
 
    <UserControl.Resources> 
        <LinearGradientBrush x:Key="DropPossibleBackground" StartPoint="0 0" EndPoint="0 1"
            <GradientStop Offset="0" Color="White" /> 
            <GradientStop Offset="1" Color="#FFE699" /> 
        </LinearGradientBrush> 
 
        <DataTemplate x:Name="GlobalProductTemplate"
            <StackPanel Margin="2" MaxWidth="200"
                <TextBlock Text="{Binding Code}" FontWeight="Bold"  /> 
                <TextBlock Text="{Binding EN_Style_Nm}" Foreground="Green"/> 
            </StackPanel> 
        </DataTemplate> 
 
    </UserControl.Resources> 
    <Grid x:Name="LayoutRoot" Margin="-9,0,9,20" RenderTransformOrigin="0.039,0.467" Height="768" VerticalAlignment="Bottom" Width="1024"
        <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="0*"></ColumnDefinition> 
            <ColumnDefinition Width="0*"/> 
            <ColumnDefinition Width="0.127*"/> 
            <ColumnDefinition Width="0.873*"/> 
        </Grid.ColumnDefinitions> 
        <Grid x:Name="Grid1" Height="768" HorizontalAlignment="Left" VerticalAlignment="Top" Width="1024" Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="1"
            <Grid.ColumnDefinitions> 
                <ColumnDefinition Width="0.032*"/> 
                <ColumnDefinition Width="0.968*"/> 
            </Grid.ColumnDefinitions> 
            <Grid.RowDefinitions> 
                <RowDefinition Height="0*"/> 
                <RowDefinition/> 
                <RowDefinition Height="0*"/> 
            </Grid.RowDefinitions> 
 
            <grid:RadGridView x:Name="RadGridView1" Foreground="Black" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" 
                    dragdrop:RadDragAndDropManager.AllowDrag="True"  HorizontalAlignment="Left" Width="829" 
                    BorderThickness="1,0,1,1" Height="363" VerticalAlignment="Top" Background="#FFCDCDCD" Margin="12,26,0,0" d:LayoutOverrides="GridBox" Grid.Column="1" Grid.Row="1"      
                        SelectionMode="Extended" ShowColumnFooters="True" ShowGroupFooters="True" MinColumnWidth="40" AutoGenerateColumns="False"
 
                <grid:RadGridView.Columns> 
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding Code}" Header="Test Code"
                        <grid:GridViewDataColumn.AggregateFunctions> 
                            <data:CountFunction Caption="Count: " /> 
                        </grid:GridViewDataColumn.AggregateFunctions> 
                    </grid:GridViewDataColumn> 
 
                </grid:RadGridView.Columns> 
 
 
            </grid:RadGridView> 
 
 
 
 
            <grid:RadGridView x:Name="RadGridView2" Foreground="Black" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" 
                    dragdrop:RadDragAndDropManager.AllowDrop="True"  HorizontalAlignment="Left" Width="822" Margin="14,0,0,40"  
                    Height="291" VerticalAlignment="Bottom" Background="#FFE3E5FF" d:LayoutOverrides="VerticalAlignment" Grid.Column="1" Grid.Row="1"       
                       RowLoaded="RadGridView2_RowLoaded" ShowColumnFooters="True" ShowGroupFooters="True" > 
                <grid:RadGridView.AlternateRowBackground> 
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"
                        <GradientStop Color="Gainsboro" Offset="0"/> 
                        <GradientStop Color="#FF3455EA" Offset="1"/> 
                    </LinearGradientBrush> 
                </grid:RadGridView.AlternateRowBackground> 
                <grid:RadGridView.Effect> 
                    <DropShadowEffect/> 
                </grid:RadGridView.Effect> 
 
            </grid:RadGridView> 
 
        </Grid> 
    </Grid> 
</UserControl> 
 

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Shapes; 
using Telerik.Windows.Controls.DragDrop; 
using Telerik.Windows.Controls.GridView; 
using Telerik.Windows.Controls; 
using Telerik.Windows.Controls.TreeView; 
using System.Collections; 
using Telerik.Windows; 
using Telerik.Windows.Data; 
 
namespace MMXPrototype 
    public partial class MainPage : UserControl 
    { 
        private RadGridViewSettings settings1 = null
        private RadGridViewSettings settings2 = null
 
        public MainPage() 
        { 
             
 
 
            InitializeComponent(); 
 
            this.Loaded += Example_Loaded; 
            Application.Current.Exit += new EventHandler(Current_Exit); 
 
            List<Product_Global_Line> GLine = new List<Product_Global_Line>(); 
           GLine.Add(new Product_Global_Line() { Code = "365775-004", EN_Style_Nm = "NIKE AIR DOWNSHIFTER II MSL", EN_Color_Desc = "BLACK/MTLC COOL GREY-CHLLNG RD", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 58, US_Whole = 29, US_FOB = 11.21, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM727" }); 
            GLine.Add(new Product_Global_Line() { Code = "365775-111", EN_Style_Nm = "NIKE AIR DOWNSHIFTER II MSL", EN_Color_Desc = "WHITEW/HITE-WHITE", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 58, US_Whole = 29, US_FOB = 11.25, US_SIZE = "4", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM727" }); 
            GLine.Add(new Product_Global_Line() { Code = "365775-103", EN_Style_Nm = "NIKE AIR DOWNSHIFTER II MSL", EN_Color_Desc = "WHITE/MTLLC SILVER-MDNGHT NVY", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 58, US_Whole = 29, US_FOB = 11.22, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM727" }); 
            GLine.Add(new Product_Global_Line() { Code = "366018-001", EN_Style_Nm = "AIR HIPPOCRENE II AP", EN_Color_Desc = "BLACK/BLACK-MTLLC SILVER-WHT", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/C", US_Retail = 50, US_Whole = 27, US_FOB = 13.64, US_SIZE = "3.5-12", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR421" }); 
            GLine.Add(new Product_Global_Line() { Code = "366018-111", EN_Style_Nm = "AIR HIPPOCRENE II AP", EN_Color_Desc = "WHITE/WHITE-METALLIC SILVER", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/C", US_Retail = 50, US_Whole = 27, US_FOB = 13.72, US_SIZE = "3.5-12", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR421" }); 
            GLine.Add(new Product_Global_Line() { Code = "366018-002", EN_Style_Nm = "AIR HIPPOCRENE II AP", EN_Color_Desc = "NTRL GRY/BLCK-MTLLC SLVR-SPRT", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 50, US_Whole = 27, US_FOB = 13.67, US_SIZE = "6-13", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR509" }); 
            GLine.Add(new Product_Global_Line() { Code = "366018-141", EN_Style_Nm = "AIR HIPPOCRENE II AP", EN_Color_Desc = "WHITE/MIDNIGHT NAVY-MTLLC SLVR", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 50, US_Whole = 27, US_FOB = 13.67, US_SIZE = "6-13", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR509" }); 
            GLine.Add(new Product_Global_Line() { Code = "343874-003", EN_Style_Nm = "AIR RAKUR 4E AP", EN_Color_Desc = "STEALTH/STEALTH-TM RD-NTRL GRY", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 60, US_Whole = 30, US_FOB = 11.86, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR507" }); 
            GLine.Add(new Product_Global_Line() { Code = "343874-002", EN_Style_Nm = "AIR RAKUR 4E AP", EN_Color_Desc = "BLACK/ANTHRACITE-MTLLC SILVER", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 60, US_Whole = 30, US_FOB = 11.85, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR507" }); 
            GLine.Add(new Product_Global_Line() { Code = "316371-062", EN_Style_Nm = "DART 4 PLUS", EN_Color_Desc = "BLACK/VARSITY RED-BLACK", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 50, US_Whole = 25, US_FOB = 13.34, US_SIZE = "6-13", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR505" }); 
            GLine.Add(new Product_Global_Line() { Code = "316371-104", EN_Style_Nm = "DART 4 PLUS", EN_Color_Desc = "WHITE/METALLIC SILVER-ESTADIO", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 50, US_Whole = 25, US_FOB = 13.34, US_SIZE = "6-13", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR505" }); 
            GLine.Add(new Product_Global_Line() { Code = "316371-442", EN_Style_Nm = "DART 4 PLUS", EN_Color_Desc = "MDNGHT NVY/MDNGHT NVY-MTLLC SL", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 50, US_Whole = 25, US_FOB = 13.34, US_SIZE = "6-13", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR505" }); 
            GLine.Add(new Product_Global_Line() { Code = "366160-004", EN_Style_Nm = "DART VII MSL", EN_Color_Desc = "DARK GREY/MTLC COOL GREY-WHITE", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 55, US_Whole = 26.54, US_FOB = 11.2, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM713" }); 
            GLine.Add(new Product_Global_Line() { Code = "366160-002", EN_Style_Nm = "DART VII MSL", EN_Color_Desc = "BLACK/MTLC COOL GREY-DARK GREY", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 55, US_Whole = 26.54, US_FOB = 10.93, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM713" }); 
            GLine.Add(new Product_Global_Line() { Code = "366160-111", EN_Style_Nm = "DART VII MSL", EN_Color_Desc = "WHITE/WHITE-METALLIC SILVER", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 55, US_Whole = 26.54, US_FOB = 11.22, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM713" }); 
 
 
            RadGridView1.ItemsSource = GLine; 
 
            //List<Product_Territory_Line> TLine1 = new List<Product_Territory_Line>(); 
            //TLine1.Add(new Product_Territory_Line { Territory_Name = "CHINA" }); 
 
            List<Product_Global_Line> GLine1 = new List<Product_Global_Line>(); 
            GLine1.Add(new Product_Global_Line() { Code = "000000-000", EN_Style_Nm = "DXXXXX", EN_Color_Desc = "XXXXXXXXXXX", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 55, US_Whole = 26.5, US_FOB = 11.22, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM713" }); 
 
 
            RadGridView2.ItemsSource = GLine1; 
 
 
 
            RadDragAndDropManager.AddDragQueryHandler(RadGridView1, OnGV1DragQuery); 
            RadDragAndDropManager.AddDragInfoHandler(RadGridView1, OnGV1DragInfo); 
 
            RadDragAndDropManager.AddDropQueryHandler(RadGridView2, OnGV2DropQuery); 
            RadDragAndDropManager.AddDropInfoHandler(RadGridView2, OnGV2DropInfo); 
        } 
 
        private void OnGV1DragQuery(object sender, DragDropQueryEventArgs e) 
        { 
            if (e.Options.Source is GridViewHeaderCell || e.Options.Source is GridViewGroupPanelCell || e.Options.Source is GridViewScrollViewer) 
                return
 
            RadGridView gridView = sender as RadGridView; 
            if (gridView != null
            { 
                IList selectedItems = gridView.SelectedItems.ToList(); 
                e.QueryResult = selectedItems.Count > 0; 
                e.Options.Payload = selectedItems; 
            } 
            var cue = new TreeViewDragCue(); 
            cue.DragActionContent = "I AM BEING DRAGGING..."
 
            e.Options.DragCue = cue; 
            e.QueryResult = true
            e.Handled = true
        } 
 
 
        private void OnGV1DragInfo(object sender, DragDropEventArgs e) 
        { 
            if (e.Options.Source is GridViewHeaderCell || e.Options.Source is GridViewGroupPanelCell || e.Options.Source is GridViewScrollViewer) 
                return
 
            RadGridView gridView = sender as RadGridView; 
            IEnumerable draggedItems = e.Options.Payload as IEnumerable; 
 
            if (e.Options.Status == DragStatus.DragInProgress) 
            { 
                //Set up a drag cue:   
                TreeViewDragCue cue = new TreeViewDragCue(); 
                //Here we need to choose a template for the items:   
                cue.ItemTemplate = this.Resources["GlobalProductTemplate"as DataTemplate; 
                cue.ItemsSource = draggedItems; 
                e.Options.DragCue = cue; 
            } 
            else if (e.Options.Status == DragStatus.DragComplete) 
            { 
                IList source = gridView.ItemsSource as IList; 
                foreach (object draggedItem in draggedItems) 
                { 
                    source.Remove(draggedItem); 
                } 
            } 
        } 
 
 
 
 
        private void OnGV2DropQuery(object sender, DragDropQueryEventArgs e) 
        { 
            if (e.Options.Source is GridViewHeaderCell || e.Options.Source is GridViewGroupPanelCell || e.Options.Source is GridViewScrollViewer) 
                return
 
            // We allow drop only if the dragged items are products:   
            ICollection draggedItems = e.Options.Payload as ICollection; 
            bool result = draggedItems.Cast<object>().All((object item) => item is Product_Global_Line); 
            e.QueryResult = result; 
            e.Handled = true
 
            if (result) 
            { 
                TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue; 
                cue.IsDropPossible = true
            } 
 
            // Note that here we agree to accept a drop. We will be notified   
            // in the DropInfo event whether a drop is actually possible.   
 
        } 
 
        private void OnGV2DropInfo(object sender, DragDropEventArgs e) 
        { 
            if (e.Options.Source is GridViewHeaderCell || e.Options.Source is GridViewGroupPanelCell || e.Options.Source is GridViewScrollViewer) 
                return
 
            RadGridView GProduct = e.Options.Destination as RadGridView; 
            ICollection draggedItems = e.Options.Payload as ICollection; 
 
            // Get the drag cu that the TreeView or we have created   
            TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue; 
 
            if (e.Options.Status == DragStatus.DropPossible) 
            { 
                // Set a suitable text:   
                string newString; 
                //newString = String.Format("Add {0}", draggedItems.Count); 
                newString = String.Format("Add {0} ", draggedItems.Count); 
                cue.DragActionContent = newString; 
 
                cue.IsDropPossible = true
                //order.Background = this.Resources["DropPossibleBackground"] as Brush; 
            } 
            else if (e.Options.Status == DragStatus.DropImpossible) 
            { 
                cue.DragActionContent = null
                cue.IsDropPossible = false
            } 
            else if (e.Options.Status == DragStatus.DropComplete) 
            { 
                //IList<Product_Global_Line> items = new List<Product_Global_Line>(); 
 
                IList items = new List<Product_Global_Line>(); 
                //IList items = GProduct.ItemsSource as IList; 
 
                items = (IList) GProduct.ItemsSource; 
 
 
                    foreach (object draggedItem in draggedItems) 
                    { 
                         
                        items.Add(draggedItem); 
                    } 
 
                 
                RadGridView2.Rebind(); 
 
 
            } 
 
            //if (e.Options.Status != DragStatus.DropPossible) 
            //{ 
            //    order.Background = new SolidColorBrush(Colors.White); 
            //} 
 
       
        } 
 
        private void RadGridView2_RowLoaded(object sender, RowLoadedEventArgs e) 
        { 
            //GridViewRow row = e.Row as GridViewRow; 
            //if (row != null) 
            //{ 
            //    Product_Territory_Line tline = row.DataContext as Product_Territory_Line; 
            //    if (row != null && tline != null) 
            //    { 
            //        row.IsExpandable = tline.Territory_Name  == "China" || tline.Territory_Name == "Japan"; 
            //    } 
            //    else 
            //    { 
            //        row.IsExpandable = false; 
            //    } 
            //} 
        } 
 
 
        void Example_Loaded(object sender, EventArgs e) 
        { 
 
            settings1 = new RadGridViewSettings(RadGridView1); 
            settings2 = new RadGridViewSettings(RadGridView2); 
            settings1.LoadState(); 
            settings2.LoadState(); 
            //settings1.ResetState(); 
            //settings2.ResetState(); 
        } 
 
        void Current_Exit(object sender, EventArgs e) 
        { 
            this.settings1.SaveState(); 
            this.settings2.SaveState(); 
        } 
    } 
 




using System; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Documents; 
using System.Windows.Ink; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Shapes; 
using System.Collections; 
using Telerik.Windows.Controls; 
using Telerik.Windows.Controls.TreeView; 
using System.Collections.ObjectModel; 
using Telerik.Windows.Data; 
using Telerik.Windows.Controls.GridView; 
using System.ComponentModel; 
 
 
namespace MMXPrototype 
    public class Product_Global_Line : INotifyPropertyChanged 
    { 
 
        private string code; 
 
        public string Code 
        { 
            get 
            { 
                return code; 
            } 
            set 
            { 
                code = value; 
                this.OnPropertyChanged("Code"); 
            } 
        } 
 
        private string en_Style_Nm; 
 
        public string EN_Style_Nm 
        { 
            get 
            { 
                return en_Style_Nm; 
            } 
            set 
            { 
                en_Style_Nm = value; 
                this.OnPropertyChanged("EN_Style_Nm"); 
            } 
        } 
 
        private string en_Color_Desc; 
 
        public string EN_Color_Desc 
        { 
            get 
            { 
                return en_Color_Desc; 
            } 
            set 
            { 
                en_Color_Desc = value; 
                this.OnPropertyChanged("EN_Color_Desc"); 
            } 
        } 
 
        private string us_Categ; 
 
        public string US_Categ 
        { 
            get 
            { 
                return us_Categ; 
            } 
            set 
            { 
                us_Categ = value; 
                this.OnPropertyChanged("US_Categ"); 
            } 
        } 
 
        private string us_Line; 
 
        public string US_Line 
        { 
            get 
            { 
                return us_Line; 
            } 
            set 
            { 
                us_Line = value; 
                this.OnPropertyChanged("US_Line"); 
            } 
        } 
 
        private string us_Gender; 
 
        public string US_Gender 
        { 
            get 
            { 
                return us_Gender; 
            } 
            set 
            { 
                us_Gender = value; 
                this.OnPropertyChanged("US_Gender"); 
            } 
        } 
 
        private string glob_Cat; 
 
        public string Glob_Cat 
        { 
            get 
            { 
                return glob_Cat; 
            } 
            set 
            { 
                glob_Cat = value; 
                this.OnPropertyChanged("Glob_Cat"); 
            } 
        } 
 
        private string us_Life; 
 
        public string US_Life 
        { 
            get 
            { 
                return us_Life; 
            } 
            set 
            { 
                us_Life = value; 
                this.OnPropertyChanged("US_Life"); 
            } 
        } 
 
        private decimal us_Retail; 
 
        public decimal US_Retail 
        { 
            get 
            { 
                return us_Retail; 
            } 
            set 
            { 
                us_Retail = value; 
                this.OnPropertyChanged("US_Retail"); 
            } 
        } 
 
 
        private double us_Whole; 
 
        public double US_Whole 
        { 
            get 
            { 
                return us_Whole; 
            } 
            set 
            { 
                us_Whole = value; 
                this.OnPropertyChanged("US_Whole"); 
            } 
        } 
 
        private double us_FOB; 
 
        public double US_FOB 
        { 
            get 
            { 
                return us_FOB; 
            } 
            set 
            { 
                us_FOB = value; 
                this.OnPropertyChanged("US_FOB"); 
            } 
        } 
 
        private string us_SIZE; 
 
        public string US_SIZE 
        { 
            get 
            { 
                return us_SIZE; 
            } 
            set 
            { 
                us_SIZE = value; 
                this.OnPropertyChanged("US_SIZE"); 
            } 
        } 
 
        private string factory; 
 
        public string Factory 
        { 
            get 
            { 
                return factory; 
            } 
            set 
            { 
                factory = value; 
                this.OnPropertyChanged("Factory"); 
            } 
        } 
 
        private string en_CTRY; 
 
        public string EN_CTRY 
        { 
            get 
            { 
                return en_CTRY; 
            } 
            set 
            { 
                en_CTRY = value; 
                this.OnPropertyChanged("EN_CTRY"); 
            } 
        } 
 
        private string con_Focus; 
 
        public string Con_Focus 
        { 
            get 
            { 
                return con_Focus; 
            } 
            set 
            { 
                con_Focus = value; 
                this.OnPropertyChanged("Con_Focus"); 
            } 
        } 
 
        private string con_Grp; 
 
        public string Con_Grp 
        { 
            get 
            { 
                return con_Grp; 
            } 
            set 
            { 
                con_Grp = value; 
                this.OnPropertyChanged("Con_Grp"); 
            } 
        } 
 
 
        private string con_Purpose; 
 
        public string Con_Purpose 
        { 
            get 
            { 
                return con_Purpose; 
            } 
            set 
            { 
                con_Purpose = value; 
                this.OnPropertyChanged("Con_Purpose"); 
            } 
        } 
 
        private string con_Use; 
 
        public string Con_Use 
        { 
            get 
            { 
                return con_Use; 
            } 
            set 
            { 
                con_Use = value; 
                this.OnPropertyChanged("Con_Use"); 
            } 
        } 
 
 
        private string core_Focus; 
 
        public string Core_Focus 
        { 
            get 
            { 
                return core_Focus; 
            } 
            set 
            { 
                core_Focus = value; 
                this.OnPropertyChanged("Core_Focus"); 
            } 
        } 
 
 
        private string dev_cd; 
 
        public string DEV_CD 
        { 
            get 
            { 
                return dev_cd; 
            } 
            set 
            { 
                dev_cd = value; 
                this.OnPropertyChanged("DEV_CD"); 
            } 
        } 
        #region INotifyPropertyChanged Members 
 
        public event PropertyChangedEventHandler PropertyChanged; 
        #endregion 
 
        protected virtual void OnPropertyChanged(string propertyName) 
        { 
            if (this.PropertyChanged != null
            { 
                this.PropertyChanged(thisnew PropertyChangedEventArgs(propertyName)); 
            } 
        } 
    } 
     
 
 




0
Tsvyatko
Telerik team
answered on 06 Apr 2010, 02:55 PM
Hello Brian Chung,

Below is the answers to your issues:

1) It's about column footer that I don't know why it is not working. Any idea? I try the simplest case of COUNT, it doesn't work for me ;(
Actually I want to  implement the SUM and Average function.

A - Please check the attachment. It seems that count function works correctly. Can you give some additional details about the problem you are facing and the expected behavior of this functionality.

2) For building a formula in gridview, if the US_Retail= (US_Whole * 2 + US_FOB *4) / 1.85, how can I implement it into the gridview and refresh the US_Retail when the US_Whole or US_FOB has changed?

A - The best and most natural way to do this calculation is to Make US_Retail to be calculated in your model. I have added similar functionality in the attachment as well.

Please let me know if this works for you.

Regards,
Tsvyatko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Brian Chung
Top achievements
Rank 1
answered on 08 Apr 2010, 06:05 AM
Hello Tsvyatko,

I am not sure why the count is not working in my project but now I simply use your project for building my proto.
I have 3 questions

1) When I drag a row from RadGridView1 to RadGridView2, I will get an Null exception if the RadGridView2 is empty at the beginning. (See attachment disp1). The source shouldn't be null as it will be a dragged row from RadGridView1, any idea why it happened?
(the temp. solution now is I put some dummy records at the beginning in RadGridView2, then I delete the dummy records.)

2) I created a child class (which is inherited from the parent class of RadGrid1. The only differences is 4 new attributes are introduced.) and want to render the display with Hierarchy structure in RadGrid2 after drag-drop.
However, the hierarchy just cannot show the extra attributes from the child class (see attachment disp2), any idea about this?

My objective is to show the parent attributes in RadGridView2 as header and other extra attributes from child in the child-hierarchy form, can it be done?

3) How to display an image in the GridView and which is come from a hyperlink
e.g. http://www.telerik.com/libraries/radcontrols_for_silverlight/performance_banner306.sflb
I try to use the <GridViewImageColumn> but the image cannot be shown.
I try to put the image as a part of the class member but it doesn't work... any example on this?

        private Image imageUrl; 
 
        public Image  ImageUrl 
        { 
            get 
            { 
 
                string preimglocation = "http://bml.nike.com/bml-rest/resources/proxies/categories/ftwr/styles/"
                string style = ""
                string precolor = "/colors/"
                string colornumb = ""
                string suffix = "/views/DY/sizes/2"
 
 
                style = Code.Substring(0, 6); 
                colornumb = Code.Substring(7, 3); 
 
 
                //Uri uri = new Uri(preimglocation + style + precolor + colornumb + suffix); 
 
                BitmapImage bmi = new BitmapImage(new Uri(preimglocation + style + precolor + colornumb + suffix, UriKind.RelativeOrAbsolute)); 
                imageUrl.Source  = bmi; 
                                 
                return imageUrl; 
 
            } 
            set 
            { 
                imageUrl = value; 
                this.OnPropertyChanged("ImageUrl"); 
            } 
        } 


THANK YOU SO MUCH!

Brian

Here are my coding
<UserControl  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:grid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" 
    xmlns:controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
    xmlns:gridParts="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView" 
    xmlns:local="clr-namespace:SL.MMXProto" 
    xmlns:data="clr-namespace:Telerik.Windows.Data;assembly=Telerik.Windows.Data" 
    xmlns:dragdrop="clr-namespace:Telerik.Windows.Controls.DragDrop;assembly=Telerik.Windows.Controls" 
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" 
    xmlns:telerikData="clr-namespace:Telerik.Windows.Data;assembly=Telerik.Windows.Data" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
    mc:Ignorable="d" xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" x:Class="SL.MMXProto.MainPage" 
    d:DesignWidth="640" d:DesignHeight="480" Width="1280" Height="768">  
    <UserControl.Resources> 
        <LinearGradientBrush x:Key="DropPossibleBackground" StartPoint="0 0" EndPoint="0 1">  
            <GradientStop Offset="0" Color="White" /> 
            <GradientStop Offset="1" Color="#FFE699" /> 
        </LinearGradientBrush> 
 
        <DataTemplate x:Name="GlobalProductTemplate">  
            <StackPanel Margin="2" MaxWidth="200">  
                <TextBlock Text="{Binding Code}" FontWeight="Bold"  /> 
                <TextBlock Text="{Binding EN_Style_Nm}" Foreground="Green"/>  
            </StackPanel> 
        </DataTemplate> 
 
    </UserControl.Resources> 
    <Grid x:Name="LayoutRoot" Margin="-9,0,9,20" RenderTransformOrigin="0.039,0.467" Height="768" VerticalAlignment="Bottom" Width="1280">  
        <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="0*"/>  
            <ColumnDefinition Width="0*"/>  
            <ColumnDefinition Width="0.127*"/>  
        <ColumnDefinition Width="0.873*"/>  
        </Grid.ColumnDefinitions> 
          
        <Grid x:Name="Grid1" Height="768" HorizontalAlignment="Left" VerticalAlignment="Top" Width="1280" Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="2">  
            <Grid.ColumnDefinitions> 
                <ColumnDefinition Width="0.032*"/>  
                <ColumnDefinition Width="0.968*"/>  
            </Grid.ColumnDefinitions> 
            <Grid.RowDefinitions> 
                <RowDefinition Height="0*"/>  
                <RowDefinition Height="0.092*"/>  
                <RowDefinition Height="0.908*"/>  
                <RowDefinition Height="0*"/>  
            </Grid.RowDefinitions> 
 
 
 
 
            <grid:RadGridView x:Name="RadGridView2" Foreground="Black" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible"   
                    dragdrop:RadDragAndDropManager.AllowDrop="True"  HorizontalAlignment="Left" Width="1200" Margin="9,0,0,8"    
                    Height="277" VerticalAlignment="Bottom" Background="#FFE3E5FF" Grid.Column="1" Grid.Row="2"         
                    ShowColumnFooters="True" d:LayoutOverrides="VerticalAlignment" RowLoaded="RadGridView2_RowLoaded" DataLoading="RadGridView2_DataLoading">  
                <grid:RadGridView.GroupPanelBackground> 
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">  
                        <GradientStop Color="#FFDFDFDF" Offset="1"/>  
                        <GradientStop Color="#FFC2AFFF"/>  
                    </LinearGradientBrush> 
                </grid:RadGridView.GroupPanelBackground> 
                <grid:RadGridView.AlternateRowBackground> 
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">  
                        <GradientStop Color="Gainsboro" Offset="0"/>  
                        <GradientStop Color="#FF3455EA" Offset="1"/>  
                    </LinearGradientBrush> 
                </grid:RadGridView.AlternateRowBackground> 
                <grid:RadGridView.Effect> 
                    <DropShadowEffect/> 
                </grid:RadGridView.Effect> 
                  
                <telerik:RadGridView.ChildTableDefinitions> 
                    <telerik:GridViewTableDefinition> 
                        <telerik:GridViewTableDefinition.Relation> 
                            <telerikData:PropertyRelation ParentPropertyName="Test_Releation"/>  
                        </telerik:GridViewTableDefinition.Relation> 
                    </telerik:GridViewTableDefinition> 
                </telerik:RadGridView.ChildTableDefinitions> 
                <telerik:RadGridView.Columns> 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding Code}" Header="Product Code"/>  
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding EN_Style_Nm}" Header="Style Name"/>  
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding EN_Color_Desc}" Header="Color Desc"/>  
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding US_Categ}" Header="Category"/>  
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding US_Gender}" Header="Gender"/>  
                </telerik:RadGridView.Columns> 
            </grid:RadGridView> 
              
              
              
            <grid:RadGridView x:Name="RadGridView1" Foreground="Black" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible"   
                    dragdrop:RadDragAndDropManager.AllowDrag="True"  HorizontalAlignment="Left" Width="1200" AlternationCount="3" 
                    BorderThickness="1,0,1,1" Height="363" VerticalAlignment="Top" Background="#FFCDEBFF" Margin="9,8,0,0" Grid.Column="1" Grid.Row="2"        
                        SelectionMode="Extended" ShowColumnFooters="True" ShowGroupFooters="True" MinColumnWidth="40" AutoGenerateColumns="False" AlternateRowBackground="#FFFFFEE9" d:LayoutOverrides="GridBox">  
                <grid:RadGridView.GroupPanelBackground> 
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">  
                        <GradientStop Color="#FFDFDFDF" Offset="1"/>  
                        <GradientStop Color="#FF90D7FF"/>  
                    </LinearGradientBrush> 
                </grid:RadGridView.GroupPanelBackground> 
      
                          
                <grid:RadGridView.GroupHeaderTemplate> 
                    <DataTemplate> 
                        <TextBlock Foreground="Red" Text="{Binding Group.Key}" /> 
                    </DataTemplate> 
                </grid:RadGridView.GroupHeaderTemplate> 
                <grid:RadGridView.Columns> 
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding Code}" Header="Product Code">  
                        <grid:GridViewDataColumn.AggregateFunctions> 
                            <telerikData:CountFunction Caption="Count: " /> 
                        </grid:GridViewDataColumn.AggregateFunctions> 
                    </grid:GridViewDataColumn> 
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding EN_Style_Nm}" Header="Style Name"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding EN_Color_Desc}" Header="Color Desc"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding US_Categ}" Header="Category"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding US_Line}" Header="Line"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding US_Gender}" Header="Gender"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding US_Line}" Header="US Line"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding Glob_Cat}" Header="Global Cat"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding US_Life}" Header="Life"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding US_Whole}" Header="Whls">  
                        <grid:GridViewDataColumn.AggregateFunctions> 
                            <telerikData:AverageFunction Caption="Average: " ResultFormatString="{}{0:F2}" SourceField="US_Whole"  /> 
                            <telerikData:SumFunction Caption="Sum: " ResultFormatString="{}{0:F2}" SourceField="US_Whole"  /> 
                        </grid:GridViewDataColumn.AggregateFunctions> 
                    </grid:GridViewDataColumn>                        
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding US_FOB}" Header="FOB">  
                        <grid:GridViewDataColumn.AggregateFunctions> 
                            <telerikData:AverageFunction Caption="Average: " ResultFormatString="{}{0:F2}" SourceField="US_FOB"  /> 
                            <telerikData:SumFunction Caption="Sum: " ResultFormatString="{}{0:F2}" SourceField="US_FOB"  /> 
                        </grid:GridViewDataColumn.AggregateFunctions> 
                    </grid:GridViewDataColumn> 
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding US_Retail}" Header="Retail">  
                        <grid:GridViewDataColumn.AggregateFunctions> 
                            <telerikData:AverageFunction Caption="Average: " ResultFormatString="{}{0:F2}" SourceField="US_Retail"  /> 
                            <telerikData:SumFunction Caption="Sum: " ResultFormatString="{}{0:F2}" SourceField="US_Retail"  /> 
                        </grid:GridViewDataColumn.AggregateFunctions> 
                    </grid:GridViewDataColumn> 
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding US_SIZE}" Header="Size"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding Factory}" Header="Factory"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding EN_CTRY}" Header="Country"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding Con_Focus}" Header="Focus"/>  
                      
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding Con_Grp}" Header="Group"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding Con_Purpose}" Header="Purpose"/>  
 
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding Con_Use}" Header="Use"/>  
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding Core_Focus}" Header="Core Focus"/>  
 
 
                    <grid:GridViewDataColumn  DataMemberBinding="{Binding DEV_CD}" Header="Dev CD"/>  
 
                </grid:RadGridView.Columns> 
 
 
                <grid:RadGridView.Effect> 
                    <DropShadowEffect/> 
                </grid:RadGridView.Effect> 
 
            </grid:RadGridView> 
            <grid:RadDataPager Grid.Row="2" 
                                   x:Name="radDataPager1" 
                                   PageSize="10" 
                                   Source="{Binding Items, ElementName=RadGridView1}" 
                                   DisplayMode="All" 
                                   AutoEllipsisMode="Both" 
                                   NumericButtonCount="10" 
                                   IsTotalItemCountFixed="True" 
                                   Margin="8,0,24,297" VerticalAlignment="Bottom" Grid.Column="1" Height="27"/>  
 
              
              
            </Grid> 
          
    </Grid> 
</UserControl> 
 


using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Net;  
using System.Windows;  
using System.Windows.Controls;  
using System.Windows.Documents;  
using System.Windows.Input;  
using System.Windows.Media;  
using System.Windows.Media.Animation;  
using System.Windows.Shapes;  
using Telerik.Windows.Controls.DragDrop;  
using System.Collections;  
using Telerik.Windows.Controls;  
using Telerik.Windows.Controls.TreeView;  
using System.Collections.ObjectModel;  
using Telerik.Windows.Data;  
using Telerik.Windows.Controls.GridView;  
using System.ComponentModel;  
using System.Windows.Media.Imaging;  
 
namespace SL.MMXProto  
{  
    public partial class MainPage : UserControl  
    {  
        private RadGridViewSettings settings1 = null;  
        private RadGridViewSettings settings2 = null;  
 
 
        public MainPage()  
        {  
 
            InitializeComponent();  
 
            this.Loaded += Example_Loaded;  
            Application.Current.Exit += new EventHandler(Current_Exit);  
 
            List<Product_Global_Line> GLine = new List<Product_Global_Line>();  
            GLine.Add(new Product_Global_Line() { Code = "365775-004", EN_Style_Nm = "NIKE AIR DOWNSHIFTER II MSL", EN_Color_Desc = "BLACK/MTLC COOL GREY-CHLLNG RD", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 58, US_Whole = 29, US_FOB = 11.21, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM727" });  
            GLine.Add(new Product_Global_Line() { Code = "365775-111", EN_Style_Nm = "NIKE AIR DOWNSHIFTER II MSL", EN_Color_Desc = "WHITEW/HITE-WHITE", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 58, US_Whole = 29, US_FOB = 11.25, US_SIZE = "4", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM727" });  
            GLine.Add(new Product_Global_Line() { Code = "365775-103", EN_Style_Nm = "NIKE AIR DOWNSHIFTER II MSL", EN_Color_Desc = "WHITE/MTLLC SILVER-MDNGHT NVY", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 58, US_Whole = 29, US_FOB = 11.22, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM727" });  
            GLine.Add(new Product_Global_Line() { Code = "366018-001", EN_Style_Nm = "AIR HIPPOCRENE II AP", EN_Color_Desc = "BLACK/BLACK-MTLLC SILVER-WHT", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/C", US_Retail = 50, US_Whole = 27, US_FOB = 13.64, US_SIZE = "3.5-12", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR421" });  
            GLine.Add(new Product_Global_Line() { Code = "366018-111", EN_Style_Nm = "AIR HIPPOCRENE II AP", EN_Color_Desc = "WHITE/WHITE-METALLIC SILVER", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/C", US_Retail = 50, US_Whole = 27, US_FOB = 13.72, US_SIZE = "3.5-12", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR421" });  
            GLine.Add(new Product_Global_Line() { Code = "366018-002", EN_Style_Nm = "AIR HIPPOCRENE II AP", EN_Color_Desc = "NTRL GRY/BLCK-MTLLC SLVR-SPRT", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 50, US_Whole = 27, US_FOB = 13.67, US_SIZE = "6-13", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR509" });  
            GLine.Add(new Product_Global_Line() { Code = "366018-141", EN_Style_Nm = "AIR HIPPOCRENE II AP", EN_Color_Desc = "WHITE/MIDNIGHT NAVY-MTLLC SLVR", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 50, US_Whole = 27, US_FOB = 13.67, US_SIZE = "6-13", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR509" });  
            GLine.Add(new Product_Global_Line() { Code = "343874-003", EN_Style_Nm = "AIR RAKUR 4E AP", EN_Color_Desc = "STEALTH/STEALTH-TM RD-NTRL GRY", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 60, US_Whole = 30, US_FOB = 11.86, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR507" });  
            GLine.Add(new Product_Global_Line() { Code = "343874-002", EN_Style_Nm = "AIR RAKUR 4E AP", EN_Color_Desc = "BLACK/ANTHRACITE-MTLLC SILVER", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 60, US_Whole = 30, US_FOB = 11.85, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR507" });  
            GLine.Add(new Product_Global_Line() { Code = "316371-062", EN_Style_Nm = "DART 4 PLUS", EN_Color_Desc = "BLACK/VARSITY RED-BLACK", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 50, US_Whole = 25, US_FOB = 13.34, US_SIZE = "6-13", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR505" });  
            GLine.Add(new Product_Global_Line() { Code = "316371-104", EN_Style_Nm = "DART 4 PLUS", EN_Color_Desc = "WHITE/METALLIC SILVER-ESTADIO", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 50, US_Whole = 25, US_FOB = 13.34, US_SIZE = "6-13", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR505" });  
            GLine.Add(new Product_Global_Line() { Code = "316371-442", EN_Style_Nm = "DART 4 PLUS", EN_Color_Desc = "MDNGHT NVY/MDNGHT NVY-MTLLC SL", US_Categ = "APFC", US_Line = "APFC RUNNING MENS", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 50, US_Whole = 25, US_FOB = 13.34, US_SIZE = "6-13", Factory = "FJ  ", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "APR505" });  
            GLine.Add(new Product_Global_Line() { Code = "366160-004", EN_Style_Nm = "DART VII MSL", EN_Color_Desc = "DARK GREY/MTLC COOL GREY-WHITE", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 55, US_Whole = 26.54, US_FOB = 11.2, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM713" });  
            GLine.Add(new Product_Global_Line() { Code = "366160-002", EN_Style_Nm = "DART VII MSL", EN_Color_Desc = "BLACK/MTLC COOL GREY-DARK GREY", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 55, US_Whole = 26.54, US_FOB = 10.93, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM713" });  
            GLine.Add(new Product_Global_Line() { Code = "366160-111", EN_Style_Nm = "DART VII MSL", EN_Color_Desc = "WHITE/WHITE-METALLIC SILVER", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 55, US_Whole = 26.54, US_FOB = 11.22, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM713" });  
 
 
            RadGridView1.ItemsSource = GLine;  
 
            List<Product_Global_Line> GLine1 = new List<Product_Global_Line>();  
            GLine1.Add(new Product_Global_Line() { Code = "000000-000", EN_Style_Nm = "DXXXXX", EN_Color_Desc = "XXXXXXXXXXX", US_Categ = "RUNNING", US_Line = "MENS CORE RUNNING", US_Gender = "MENS", Glob_Cat = "RUNNING", US_Life = "C/N", US_Retail = 55, US_Whole = 26.5, US_FOB = 11.22, US_SIZE = "6-13", Factory = "YT", EN_CTRY = "CHIN", Con_Focus = "RUNNING", Con_Grp = "MENS", Con_Purpose = "RUNNING", Con_Use = "MENS", Core_Focus = "RUNNING", DEV_CD = "GRM713" });  
 
 
              
 
            List<Product_Terr_Line> TLine = new List<Product_Terr_Line>();  
            TLine.Add(new Product_Terr_Line(GLine[1], "China", 125, 75, 70)  );  
            TLine.Add(new Product_Terr_Line(GLine[1], "HongKong", 100, 55, 25));  
            TLine.Add(new Product_Terr_Line(GLine[1], "Taiwan", 110, 65, 40));  
 
            RadGridView2.ItemsSource = TLine;  
 
 
 
            RadDragAndDropManager.AddDragQueryHandler(RadGridView1, OnGV1DragQuery);  
            RadDragAndDropManager.AddDragInfoHandler(RadGridView1, OnGV1DragInfo);  
 
            RadDragAndDropManager.AddDropQueryHandler(RadGridView2, OnGV2DropQuery);  
            RadDragAndDropManager.AddDropInfoHandler(RadGridView2, OnGV2DropInfo);  
        }  
 
        private void OnGV1DragQuery(object sender, DragDropQueryEventArgs e)  
        {  
            if (e.Options.Source is GridViewHeaderCell || e.Options.Source is GridViewGroupPanelCell || e.Options.Source is GridViewScrollViewer)  
                return;  
 
            RadGridView gridView = sender as RadGridView;  
            if (gridView != null)  
            {  
                IList selectedItems = gridView.SelectedItems.ToList();  
                e.QueryResult = selectedItems.Count > 0;  
                e.Options.Payload = selectedItems;  
            }  
            var cue = new TreeViewDragCue();  
            cue.DragActionContent = "I AM BEING DRAGGING...";  
 
            e.Options.DragCue = cue;  
            e.QueryResult = true;  
            e.Handled = true;  
        }  
 
 
        private void OnGV1DragInfo(object sender, DragDropEventArgs e)  
        {  
            if (e.Options.Source is GridViewHeaderCell || e.Options.Source is GridViewGroupPanelCell || e.Options.Source is GridViewScrollViewer)  
                return;  
 
            RadGridView gridView = sender as RadGridView;  
            IEnumerable draggedItems = e.Options.Payload as IEnumerable;  
 
            if (e.Options.Status == DragStatus.DragInProgress)  
            {  
                //Set up a drag cue:     
                TreeViewDragCue cue = new TreeViewDragCue();  
                //Here we need to choose a template for the items:     
                cue.ItemTemplate = this.Resources["GlobalProductTemplate"as DataTemplate;  
                cue.ItemsSource = draggedItems;  
                e.Options.DragCue = cue;  
            }  
            else if (e.Options.Status == DragStatus.DragComplete)  
            {  
                IList source = gridView.ItemsSource as IList;  
                foreach (object draggedItem in draggedItems)  
                {  
                    source.Remove(draggedItem);  
                }  
            }  
        }  
 
 
 
 
        private void OnGV2DropQuery(object sender, DragDropQueryEventArgs e)  
        {  
            if (e.Options.Source is GridViewHeaderCell || e.Options.Source is GridViewGroupPanelCell || e.Options.Source is GridViewScrollViewer)  
                return;  
 
            // We allow drop only if the dragged items are products:     
            ICollection draggedItems = e.Options.Payload as ICollection;  
            var destinationRow = e.GetElement<GridViewRow>(e.Options.CurrentDragPoint);  
 
            bool result = draggedItems.Cast<object>().All((object item) => item is Product_Global_Line) &&  
                (destinationRow != null && destinationRow.GridViewDataControl.ChildTableDefinitions.Count > 0) ||  
                destinationRow == null;  
 
            e.QueryResult = result;  
            e.Handled = true;  
 
            if (result)  
            {  
                TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue;  
                cue.IsDropPossible = true;  
            }  
 
            // Note that here we agree to accept a drop. We will be notified     
            // in the DropInfo event whether a drop is actually possible.     
 
        }  
 
        private void OnGV2DropInfo(object sender, DragDropEventArgs e)  
        {  
            if (e.Options.Source is GridViewHeaderCell || e.Options.Source is GridViewGroupPanelCell || e.Options.Source is GridViewScrollViewer)  
                return;  
 
            RadGridView GProduct = e.Options.Destination as RadGridView;  
            ICollection draggedItems = e.Options.Payload as ICollection;  
 
            // Get the drag cu that the TreeView or we have created     
            TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue;  
 
            if (e.Options.Status == DragStatus.DropPossible)  
            {  
                // Set a suitable text:     
                string newString;  
                //newString = String.Format("Add {0}", draggedItems.Count);   
                newString = String.Format("Add {0} ", draggedItems.Count);  
                cue.DragActionContent = newString;  
 
                cue.IsDropPossible = true;  
                //order.Background = this.Resources["DropPossibleBackground"] as Brush;   
            }  
            else if (e.Options.Status == DragStatus.DropImpossible)  
            {  
                cue.DragActionContent = null;  
                cue.IsDropPossible = false;  
            }  
            else if (e.Options.Status == DragStatus.DropComplete)  
            {  
                var row = e.GetElement<GridViewRow>(e.Options.CurrentDragPoint);  
   
                IList items_test = new List<Product_Terr_Line>();  
                items_test = (IList)GProduct.ItemsSource;  
 
                foreach (object draggedItem in draggedItems)  
                {  
                     
                    items_test.Add(new Product_Terr_Line((Product_Global_Line)draggedItem, "China", 125, 75, 70));  
                    items_test.Add(new Product_Terr_Line((Product_Global_Line)draggedItem, "HongKong", 100, 55, 25));  
                    items_test.Add(new Product_Terr_Line((Product_Global_Line)draggedItem, "Taiwan", 110, 65, 40));  
                }  
 
                RadGridView2.Rebind();  
 
            }  
 
            if (e.Options.Status != DragStatus.DropPossible)  
            {  
                if (GProduct != null)  
                {  
                    GProduct.Background = new SolidColorBrush(Colors.White);  
                }  
            }   
 
        }  
 
 
 
        void Example_Loaded(object sender, EventArgs e)  
        {  
 
            settings1 = new RadGridViewSettings(RadGridView1);  
            settings2 = new RadGridViewSettings(RadGridView2);  
            settings1.LoadState();  
            settings2.LoadState();  
            //settings1.ResetState();  
            //settings2.ResetState();  
        }  
 
        void Current_Exit(object sender, EventArgs e)  
        {  
            this.settings1.SaveState();  
            this.settings2.SaveState();  
        }  
 
        private void RadGridView2_RowLoaded(object sender, RowLoadedEventArgs e)  
        {  
            GridViewRow row = e.Row as GridViewRow;  
            if (row != null)  
            {  
                Product_Terr_Line tline = row.DataContext as Product_Terr_Line;  
                if (row != null && tline != null)  
                {  
                    row.IsExpandable = true;  
                }  
                else 
                {  
                    row.IsExpandable = false;  
                }  
            }  
        }  
 
        private void RadGridView2_DataLoading(object sender, GridViewDataLoadingEventArgs e)  
        {  
            GridViewDataControl dataControl = (GridViewDataControl)sender;  
            if (dataControl.ParentRow != null)  
            {  
                dataControl.CanUserFreezeColumns = false;  
                dataControl.ShowGroupPanel = false;  
                dataControl.AutoGenerateColumns = false;  
 
 
                GridViewDataColumn column = new GridViewDataColumn();  
                column.Header = "Territory";  
                column.DataMemberBinding = new System.Windows.Data.Binding("Terr");  
                dataControl.Columns.Add(column);  
 
                column = new GridViewDataColumn();  
                column.Header = "Retail";  
                column.DataFormatString = "{0:F2}";  
                column.DataMemberBinding = new System.Windows.Data.Binding("Terr_retail");  
                dataControl.Columns.Add(column);  
 
                column = new GridViewDataColumn();  
                column.Header = "Wholesales";  
                column.DataFormatString = "{0:F2}";  
                column.DataMemberBinding = new System.Windows.Data.Binding("Terr_whls");  
                dataControl.Columns.Add(column);  
 
                column = new GridViewDataColumn();  
                column.Header = "Buy";  
                column.DataMemberBinding = new System.Windows.Data.Binding("Terr_buy");  
                dataControl.Columns.Add(column);  
            }  
      
        }  
 
 
 
 
 
    }  
 
    public class Product_Global_Line : INotifyPropertyChanged  
    {  
 
        public Product_Global_Line()   
        {}  
 
        public Product_Global_Line(string code, string en_style_nm, string en_color_desc, string us_categ,   
           string us_line, string us_gender, string glob_cat, string us_life, decimal us_retail,  
            double us_whole, double us_fob, string us_size, string factory, string en_ctry,  
            string con_focus, string con_grp, string con_purpose, string con_use, string core_focus, string dev_cd  
            )  
        {  
            this.Code = code;  
            this.EN_Style_Nm = en_style_nm;  
            this.EN_Color_Desc = en_color_desc;  
            this.US_Categ = us_categ;  
            this.US_Line = us_line;  
            this.US_Gender = us_gender;  
            this.Glob_Cat = glob_cat;  
            this.US_Life = us_life;  
            this.US_Retail = us_retail;  
            this.US_Whole = us_whole;  
            this.US_FOB = us_fob;  
            this.US_SIZE = us_size;  
            this.Factory = factory;  
            this.EN_CTRY = en_ctry;  
            this.Con_Focus = con_focus;  
            this.Con_Grp = con_grp;  
            this.Con_Purpose = con_purpose;  
            this.Con_Use = con_use;  
            this.Core_Focus = core_focus;  
            this.DEV_CD = dev_cd;  
 
        }  
 
        private string code;  
 
        public string Code  
        {  
            get 
            {  
                return code;  
            }  
            set 
            {  
                code = value;  
                this.OnPropertyChanged("Code");  
            }  
        }  
 
        private string en_Style_Nm;  
 
        public string EN_Style_Nm  
        {  
            get 
            {  
                return en_Style_Nm;  
            }  
            set 
            {  
                en_Style_Nm = value;  
                this.OnPropertyChanged("EN_Style_Nm");  
            }  
        }  
 
        private string en_Color_Desc;  
 
        public string EN_Color_Desc  
        {  
            get 
            {  
                return en_Color_Desc;  
            }  
            set 
            {  
                en_Color_Desc = value;  
                this.OnPropertyChanged("EN_Color_Desc");  
            }  
        }  
 
        private string us_Categ;  
 
        public string US_Categ  
        {  
            get 
            {  
                return us_Categ;  
            }  
            set 
            {  
                us_Categ = value;  
                this.OnPropertyChanged("US_Categ");  
            }  
        }  
 
        private string us_Line;  
 
        public string US_Line  
        {  
            get 
            {  
                return us_Line;  
            }  
            set 
            {  
                us_Line = value;  
                this.OnPropertyChanged("US_Line");  
            }  
        }  
 
        private string us_Gender;  
 
        public string US_Gender  
        {  
            get 
            {  
                return us_Gender;  
            }  
            set 
            {  
                us_Gender = value;  
                this.OnPropertyChanged("US_Gender");  
            }  
        }  
 
        private string glob_Cat;  
 
        public string Glob_Cat  
        {  
            get 
            {  
                return glob_Cat;  
            }  
            set 
            {  
                glob_Cat = value;  
                this.OnPropertyChanged("Glob_Cat");  
            }  
        }  
 
        private string us_Life;  
 
        public string US_Life  
        {  
            get 
            {  
                return us_Life;  
            }  
            set 
            {  
                us_Life = value;  
                this.OnPropertyChanged("US_Life");  
            }  
        }  
 
        //private decimal us_Retail;  
 
        public decimal US_Retail  
        {  
            get 
            {  
                return Math.Round((decimal)((US_Whole * 2 + US_FOB * 4) / 10),2);  
            }  
            set 
            {  
                //us_Retail = value;  
                this.OnPropertyChanged("US_Retail");  
            }  
        }  
 
 
        private double us_Whole;  
 
        public double US_Whole  
        {  
            get 
            {  
                return us_Whole;  
            }  
            set 
            {  
                us_Whole = value;  
                this.OnPropertyChanged("US_Whole");  
                this.OnPropertyChanged("US_Retail");  
            }  
        }  
 
        private double us_FOB;  
 
        public double US_FOB  
        {  
            get 
            {  
                return us_FOB;  
            }  
            set 
            {  
                us_FOB = value;  
                this.OnPropertyChanged("US_FOB");  
                this.OnPropertyChanged("US_Retail");  
            }  
        }  
 
        private string us_SIZE;  
 
        public string US_SIZE  
        {  
            get 
            {  
                return us_SIZE;  
            }  
            set 
            {  
                us_SIZE = value;  
                this.OnPropertyChanged("US_SIZE");  
            }  
        }  
 
        private string factory;  
 
        public string Factory  
        {  
            get 
            {  
                return factory;  
            }  
            set 
            {  
                factory = value;  
                this.OnPropertyChanged("Factory");  
            }  
        }  
 
        private string en_CTRY;  
 
        public string EN_CTRY  
        {  
            get 
            {  
                return en_CTRY;  
            }  
            set 
            {  
                en_CTRY = value;  
                this.OnPropertyChanged("EN_CTRY");  
            }  
        }  
 
        private string con_Focus;  
 
        public string Con_Focus  
        {  
            get 
            {  
                return con_Focus;  
            }  
            set 
            {  
                con_Focus = value;  
                this.OnPropertyChanged("Con_Focus");  
            }  
        }  
 
        private string con_Grp;  
 
        public string Con_Grp  
        {  
            get 
            {  
                return con_Grp;  
            }  
            set 
            {  
                con_Grp = value;  
                this.OnPropertyChanged("Con_Grp");  
            }  
        }  
 
 
        private string con_Purpose;  
 
        public string Con_Purpose  
        {  
            get 
            {  
                return con_Purpose;  
            }  
            set 
            {  
                con_Purpose = value;  
                this.OnPropertyChanged("Con_Purpose");  
            }  
        }  
 
        private string con_Use;  
 
        public string Con_Use  
        {  
            get 
            {  
                return con_Use;  
            }  
            set 
            {  
                con_Use = value;  
                this.OnPropertyChanged("Con_Use");  
            }  
        }  
 
 
        private string core_Focus;  
 
        public string Core_Focus  
        {  
            get 
            {  
                return core_Focus;  
            }  
            set 
            {  
                core_Focus = value;  
                this.OnPropertyChanged("Core_Focus");  
            }  
        }  
 
 
        private string dev_cd;  
 
        public string DEV_CD  
        {  
            get 
            {  
                return dev_cd;  
            }  
            set 
            {  
                dev_cd = value;  
                this.OnPropertyChanged("DEV_CD");  
            }  
        }
        #region INotifyPropertyChanged Members  
 
        public event PropertyChangedEventHandler PropertyChanged;
        #endregion  
 
        protected virtual void OnPropertyChanged(string propertyName)  
        {  
            if (this.PropertyChanged != null)  
            {  
                this.PropertyChanged(thisnew PropertyChangedEventArgs(propertyName));  
            }  
        }  
    }// end Product_Global_Line class  
 
 
    public class Product_Terr_Line : Product_Global_Line  
    {  
 
        public Product_Terr_Line() : base()  
        {}  
 
 
        public Product_Terr_Line(Product_Global_Line PLine, string terr, double terr_retail, double terr_whls, int terr_buy)            
        {  
            this.Terr = terr;  
            this.Terr_retail = terr_retail;  
            this.Terr_whls = terr_whls;  
            this.Terr_buy = terr_buy;  
 
            this.Code = PLine.Code;  
            this.EN_Style_Nm = PLine.EN_Style_Nm;  
            this.EN_Color_Desc = PLine.EN_Color_Desc;  
            this.US_Categ = PLine.US_Categ;  
            this.US_Line = PLine.US_Line;  
            this.US_Gender = PLine.US_Gender;  
            this.Glob_Cat = PLine.Glob_Cat;  
            this.US_Life = PLine.US_Life;  
            this.US_Retail = PLine.US_Retail;  
            this.US_Whole = PLine.US_Whole;  
            this.US_FOB = PLine.US_FOB;  
            this.US_SIZE = PLine.US_SIZE;  
            this.Factory = PLine.Factory;  
            this.EN_CTRY = PLine.EN_CTRY;  
            this.Con_Focus = PLine.Core_Focus;  
            this.Con_Grp = PLine.Con_Grp;  
            this.Con_Purpose = PLine.Con_Purpose;  
            this.Con_Use = PLine.Con_Use;  
            this.Core_Focus = PLine.Con_Focus;  
            this.DEV_CD = PLine.DEV_CD;  
        }  
 
 
        private string terr;  
 
        public string Terr  
        {  
            get 
            {  
                return terr;  
            }  
            set 
            {  
                terr = value;  
                this.OnPropertyChanged("Terr");  
            }  
        }  
 
        private double terr_retail;  
 
        public double Terr_retail  
        {  
            get 
            {  
                return terr_retail;  
            }  
            set 
            {  
                terr_retail = value;  
                this.OnPropertyChanged("Terr_retail");  
            }  
        }  
 
        private double terr_whls;  
 
        public double Terr_whls  
        {  
            get 
            {  
                return terr_whls;  
            }  
            set 
            {  
                terr_whls = value;  
                this.OnPropertyChanged("Terr_whls");  
            }  
        }  
 
        private double terr_buy;  
 
        public double Terr_buy  
        {  
            get 
            {  
                return terr_buy;  
            }  
            set 
            {  
                terr_buy = value;  
                this.OnPropertyChanged("Terr_buy");  
            }  
        }  
 
 
 
    } // end Product_Terr_line class   
 
}  
 


using System;  
using System.Net;  
using System.Windows;  
using System.Windows.Controls;  
using System.Windows.Documents;  
using System.Windows.Ink;  
using System.Windows.Input;  
using System.Windows.Media;  
using System.Windows.Media.Animation;  
using System.Windows.Shapes;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Configuration;  
using System.ComponentModel;  
using System.Windows.Data;  
using Telerik.Windows.Controls;  
using Telerik.Windows.Data;  
using Telerik.Windows.Controls.GridView;  
using System.Runtime.Serialization;  
using System.IO;  
using System.IO.IsolatedStorage;  
 
namespace SL.MMXProto  
{  
    public class RadGridViewSettings  
    {  
 
            public RadGridViewSettings()  
            {  
                //  
            }  
 
            public class RadGridViewApplicationSettings : Dictionary<stringobject>  
            {  
                private RadGridViewSettings settings;  
 
                private DataContractSerializer serializer = null;  
 
                public RadGridViewApplicationSettings()  
                {  
                    //  
                }  
 
                public RadGridViewApplicationSettings(RadGridViewSettings settings)  
                {  
                    this.settings = settings;  
 
                    List<Type> types = new List<Type>();  
                    types.Add(typeof(List<ColumnSetting>));  
                    types.Add(typeof(List<FilterSetting>));  
                    types.Add(typeof(List<GroupSetting>));  
                    types.Add(typeof(List<SortSetting>));  
                    types.Add(typeof(List<PropertySetting>));  
 
                    this.serializer = new DataContractSerializer(typeof(RadGridViewApplicationSettings), types);  
                }  
 
                public string PersistID  
                {  
                    get 
                    {  
                        if (!ContainsKey("PersistID") && settings.grid != null)  
                        {  
                            this["PersistID"] = settings.grid.Name;  
                        }  
 
                        return (string)this["PersistID"];  
                    }  
                }  
 
                public int FrozenColumnCount  
                {  
                    get 
                    {  
                        if (!ContainsKey("FrozenColumnCount"))  
                        {  
                            this["FrozenColumnCount"] = 0;  
                        }  
 
                        return (int)this["FrozenColumnCount"];  
                    }  
                    set 
                    {  
                        this["FrozenColumnCount"] = value;  
                    }  
                }  
 
                public List<ColumnSetting> ColumnSettings  
                {  
                    get 
                    {  
                        if (!ContainsKey("ColumnSettings"))  
                        {  
                            this["ColumnSettings"] = new List<ColumnSetting>();  
                        }  
 
                        return (List<ColumnSetting>)this["ColumnSettings"];  
                    }  
                }  
 
                public List<SortSetting> SortSettings  
                {  
                    get 
                    {  
                        if (!ContainsKey("SortSettings"))  
                        {  
                            this["SortSettings"] = new List<SortSetting>();  
                        }  
 
                        return (List<SortSetting>)this["SortSettings"];  
                    }  
                }  
 
                public List<GroupSetting> GroupSettings  
                {  
                    get 
                    {  
                        if (!ContainsKey("GroupSettings"))  
                        {  
                            this["GroupSettings"] = new List<GroupSetting>();  
                        }  
 
                        return (List<GroupSetting>)this["GroupSettings"];  
                    }  
                }  
 
                public List<FilterSetting> FilterSettings  
                {  
                    get 
                    {  
                        if (!ContainsKey("FilterSettings"))  
                        {  
                            this["FilterSettings"] = new List<FilterSetting>();  
                        }  
 
                        return (List<FilterSetting>)this["FilterSettings"];  
                    }  
                }  
 
                public void Reload()  
                {  
                    try 
                    {  
                        using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())  
                        {  
                            using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(PersistID, FileMode.Open, file))  
                            {  
                                if (stream.Length > 0)  
                                {  
                                    RadGridViewApplicationSettings loaded = (RadGridViewApplicationSettings)serializer.ReadObject(stream);  
 
                                    FrozenColumnCount = loaded.FrozenColumnCount;  
 
                                    ColumnSettings.Clear();  
                                    foreach (ColumnSetting cs in loaded.ColumnSettings)  
                                    {  
                                        ColumnSettings.Add(cs);  
                                    }  
 
                                    FilterSettings.Clear();  
                                    foreach (FilterSetting fs in loaded.FilterSettings)  
                                    {  
                                        FilterSettings.Add(fs);  
                                    }  
 
                                    GroupSettings.Clear();  
                                    foreach (GroupSetting gs in loaded.GroupSettings)  
                                    {  
                                        GroupSettings.Add(gs);  
                                    }  
 
                                    SortSettings.Clear();  
                                    foreach (SortSetting ss in loaded.SortSettings)  
                                    {  
                                        SortSettings.Add(ss);  
                                    }  
                                }  
                            }  
                        }  
                    }  
                    catch 
                    {  
 
                    }  
                }  
 
                public void Reset()  
                {  
                    try 
                    {  
                        using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())  
                        {  
                            file.DeleteFile(PersistID);  
                        }  
                    }  
                    catch 
                    {  
                        //  
                    }  
                }  
 
                public void Save()  
                {  
                    try 
                    {  
                        using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())  
                        {  
                            using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(PersistID, FileMode.Create, file))  
                            {  
                                serializer.WriteObject(stream, this);  
                            }  
                        }  
                    }  
                    catch 
                    {  
                        //  
                    }  
                }  
            }  
 
            private RadGridView grid = null;  
 
            public RadGridViewSettings(RadGridView grid)  
            {  
                this.grid = grid;  
            }  
 
            public static readonly DependencyProperty IsEnabledProperty  
               = DependencyProperty.RegisterAttached("IsEnabled"typeof(bool), typeof(RadGridViewSettings),  
                    new PropertyMetadata(new PropertyChangedCallback(OnIsEnabledPropertyChanged)));  
 
            public static bool GetIsEnabled(DependencyObject dependencyObject)  
            {  
                return (bool)dependencyObject.GetValue(IsEnabledProperty);  
            }  
 
            public static void SetIsEnabled(DependencyObject dependencyObject, bool enabled)  
            {  
                dependencyObject.SetValue(IsEnabledProperty, enabled);  
            }  
 
            private static void OnIsEnabledPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)  
            {  
                RadGridView grid = dependencyObject as RadGridView;  
                if (grid != null)  
                {  
                    if ((bool)e.NewValue)  
                    {  
                        RadGridViewSettings settings = new RadGridViewSettings(grid);  
                        settings.Attach();  
                    }  
                }  
            }  
 
            public virtual void LoadState()  
            {  
                try 
                {  
                    Settings.Reload();  
                }  
                catch 
                {  
                    Settings.Reset();  
                }  
 
                if (this.grid != null)  
                {  
                    grid.FrozenColumnCount = Settings.FrozenColumnCount;  
 
                    if (Settings.ColumnSettings.Count > 0)  
                    {  
                        grid.AutoGenerateColumns = false;  
                        grid.Columns.Clear();  
 
                        foreach (ColumnSetting setting in Settings.ColumnSettings)  
                        {  
                            GridViewDataColumn column = new GridViewDataColumn();  
                            column.UniqueName = setting.UniqueName;  
                            column.DataMemberBinding = new Binding(setting.PropertyName);  
                            column.Header = setting.Header;  
 
                            if (setting.Width != null)  
                            {  
                                column.Width = new GridViewLength(setting.Width.Value);  
                            }  
 
                            grid.Columns.Add(column);  
                        }  
 
                        foreach (ColumnSetting setting in Settings.ColumnSettings)  
                        {  
                            ColumnSetting currentSetting = setting;  
 
                            GridViewDataColumn column = (from c in grid.Columns.OfType<GridViewDataColumn>()  
                                                         where c.UniqueName == currentSetting.UniqueName  
                                                         select c).FirstOrDefault();  
 
                            if (currentSetting.DisplayIndex != null)  
                            {  
                                column.DisplayIndex = currentSetting.DisplayIndex.Value;  
                            }  
                        }  
                    }  
                    using (grid.DeferRefresh())  
                    {  
                        if (Settings.SortSettings.Count > 0)  
                        {  
                            grid.SortDescriptors.Clear();  
 
                            foreach (SortSetting setting in Settings.SortSettings)  
                            {  
                                Telerik.Windows.Data.SortDescriptor d = new Telerik.Windows.Data.SortDescriptor();  
                                d.Member = setting.PropertyName;  
                                d.SortDirection = setting.SortDirection;  
 
                                grid.SortDescriptors.Add(d);  
                            }  
                        }  
 
                        if (Settings.GroupSettings.Count > 0)  
                        {  
                            grid.GroupDescriptors.Clear();  
 
                            foreach (GroupSetting setting in Settings.GroupSettings)  
                            {  
                                Telerik.Windows.Data.GroupDescriptor d = new Telerik.Windows.Data.GroupDescriptor();  
                                d.Member = setting.PropertyName;  
                                d.SortDirection = setting.SortDirection;  
                                d.DisplayContent = setting.DisplayContent;  
 
                                grid.GroupDescriptors.Add(d);  
                            }  
                        }  
 
                        if (Settings.FilterSettings.Count > 0)  
                        {  
                            foreach (FilterSetting setting in Settings.FilterSettings)  
                            {  
                                FilterSetting currentSetting = setting;  
 
                                GridViewDataColumn matchingColumn =  
                                (from column in grid.Columns.OfType<GridViewDataColumn>()  
                                 where column.DataMemberBinding.Path.Path == currentSetting.PropertyName  
                                 select column).FirstOrDefault();  
 
                                if (matchingColumn != null)  
                                {  
                                    ColumnFilterDescriptor cfd = new ColumnFilterDescriptor(matchingColumn);  
 
                                    cfd.FieldFilter.Filter1.Member = setting.Filter1.Member;  
                                    cfd.FieldFilter.Filter1.Operator = setting.Filter1.Operator;  
                                    cfd.FieldFilter.Filter1.Value = setting.Filter1.Value;  
 
                                    cfd.FieldFilter.Filter2.Member = setting.Filter2.Member;  
                                    cfd.FieldFilter.Filter2.Operator = setting.Filter2.Operator;  
                                    cfd.FieldFilter.Filter2.Value = setting.Filter2.Value;  
 
                                    foreach (Telerik.Windows.Data.FilterDescriptor descriptor in setting.SelectedDistinctValues)  
                                    {  
                                        cfd.DistinctFilter.FilterDescriptors.Add(descriptor);  
                                    }  
 
                                    this.grid.FilterDescriptors.Add(cfd);  
                                }  
                            }  
                        }  
                    }  
                }  
            }  
 
            public virtual void ResetState()  
            {  
                Settings.Reset();  
            }  
 
            public virtual void SaveState()  
            {  
                Settings.Reset();  
 
                if (grid != null)  
                {  
                    if (grid.Columns != null)  
                    {  
                        Settings.ColumnSettings.Clear();  
 
                        foreach (GridViewColumn column in grid.Columns)  
                        {  
                            if (column is GridViewDataColumn)  
                            {  
                                GridViewDataColumn dataColumn = (GridViewDataColumn)column;  
 
                                ColumnSetting setting = new ColumnSetting();  
                                setting.PropertyName = dataColumn.DataMemberBinding.Path.Path;  
                                setting.UniqueName = dataColumn.UniqueName;  
                                setting.Header = dataColumn.Header;  
                                setting.Width = dataColumn.ActualWidth;  
                                setting.DisplayIndex = dataColumn.DisplayIndex;  
 
                                Settings.ColumnSettings.Add(setting);  
                            }  
                        }  
                    }  
 
                    if (grid.FilterDescriptors != null)  
                    {  
                        Settings.FilterSettings.Clear();  
 
                        foreach (IColumnFilterDescriptor cfd in grid.FilterDescriptors.OfType<IColumnFilterDescriptor>())  
                        {  
                            FilterSetting setting = new FilterSetting();  
 
                            setting.Filter1 = new Telerik.Windows.Data.FilterDescriptor();  
                            setting.Filter1.Member = cfd.FieldFilter.Filter1.Member;  
                            setting.Filter1.Operator = cfd.FieldFilter.Filter1.Operator;  
                            setting.Filter1.Value = cfd.FieldFilter.Filter1.Value;  
                            setting.Filter1.MemberType = null;  
 
                            setting.Filter2 = new Telerik.Windows.Data.FilterDescriptor();  
                            setting.Filter2.Member = cfd.FieldFilter.Filter2.Member;  
                            setting.Filter2.Operator = cfd.FieldFilter.Filter2.Operator;  
                            setting.Filter2.Value = cfd.FieldFilter.Filter2.Value;  
                            setting.Filter2.MemberType = null;  
 
                            foreach (Telerik.Windows.Data.FilterDescriptor fd in cfd.DistinctFilter.FilterDescriptors.OfType<Telerik.Windows.Data.FilterDescriptor>())  
                            {  
                                Telerik.Windows.Data.FilterDescriptor newFd = new Telerik.Windows.Data.FilterDescriptor();  
                                newFd.Member = fd.Member;  
                                newFd.Operator = fd.Operator;  
                                newFd.Value = fd.Value;  
                                newFd.MemberType = null;  
                                setting.SelectedDistinctValues.Add(newFd);  
                            }  
 
                            setting.PropertyName = cfd.Column.DataMemberBinding.Path.Path;  
 
                            Settings.FilterSettings.Add(setting);  
                        }  
                    }  
 
                    if (grid.SortDescriptors != null)  
                    {  
                        Settings.SortSettings.Clear();  
 
                        foreach (Telerik.Windows.Data.SortDescriptor d in grid.SortDescriptors)  
                        {  
                            SortSetting setting = new SortSetting();  
 
                            setting.PropertyName = d.Member;  
                            setting.SortDirection = d.SortDirection;  
 
                            Settings.SortSettings.Add(setting);  
                        }  
                    }  
 
                    if (grid.GroupDescriptors != null)  
                    {  
                        Settings.GroupSettings.Clear();  
 
                        foreach (Telerik.Windows.Data.GroupDescriptor d in grid.GroupDescriptors)  
                        {  
                            GroupSetting setting = new GroupSetting();  
 
                            setting.PropertyName = d.Member;  
                            setting.SortDirection = d.SortDirection;  
                            setting.DisplayContent = d.DisplayContent;  
 
                            Settings.GroupSettings.Add(setting);  
                        }  
                    }  
 
                    Settings.FrozenColumnCount = grid.FrozenColumnCount;  
                }  
 
                Settings.Save();  
            }  
 
            private void Attach()  
            {  
                if (this.grid != null)  
                {  
                    this.grid.LayoutUpdated += new EventHandler(LayoutUpdated);  
                    this.grid.Loaded += Loaded;  
                    Application.Current.Exit += Current_Exit;  
                }  
            }  
 
            void Current_Exit(object sender, EventArgs e)  
            {  
                SaveState();  
            }  
 
            void Loaded(object sender, EventArgs e)  
            {  
                LoadState();  
            }  
 
            void LayoutUpdated(object sender, EventArgs e)  
            {  
                if (grid.Parent == null)  
                {  
                    SaveState();  
                }  
            }  
 
            private RadGridViewApplicationSettings gridViewApplicationSettings = null;  
 
            protected virtual RadGridViewApplicationSettings CreateRadGridViewApplicationSettingsInstance()  
            {  
                return new RadGridViewApplicationSettings(this);  
            }  
 
            protected RadGridViewApplicationSettings Settings  
            {  
                get 
                {  
                    if (gridViewApplicationSettings == null)  
                    {  
                        gridViewApplicationSettings = CreateRadGridViewApplicationSettingsInstance();  
                    }  
                    return gridViewApplicationSettings;  
                }  
            }  
        }  
 
        public class PropertySetting  
        {  
            string _PropertyName;  
            public string PropertyName  
            {  
                get 
                {  
                    return _PropertyName;  
                }  
                set 
                {  
                    _PropertyName = value;  
                }  
            }  
        }  
 
        public class SortSetting : PropertySetting  
        {  
            ListSortDirection _SortDirection;  
            public ListSortDirection SortDirection  
            {  
                get 
                {  
                    return _SortDirection;  
                }  
                set 
                {  
                    _SortDirection = value;  
                }  
            }  
        }  
 
        public class GroupSetting : PropertySetting  
        {  
            object _DisplayContent;  
            public object DisplayContent  
            {  
                get 
                {  
                    return _DisplayContent;  
                }  
                set 
                {  
                    _DisplayContent = value;  
                }  
            }  
 
            ListSortDirection? _SortDirection;  
            public ListSortDirection? SortDirection  
            {  
                get 
                {  
                    return _SortDirection;  
                }  
                set 
                {  
                    _SortDirection = value;  
                }  
            }  
        }  
 
        public class FilterSetting : PropertySetting  
        {  
            List<Telerik.Windows.Data.FilterDescriptor> _SelectedDistinctValues;  
            public List<Telerik.Windows.Data.FilterDescriptor> SelectedDistinctValues  
            {  
                get 
                {  
                    if (_SelectedDistinctValues == null)  
                    {  
                        _SelectedDistinctValues = new List<Telerik.Windows.Data.FilterDescriptor>();  
                    }  
                    return _SelectedDistinctValues;  
                }  
            }  
 
            Telerik.Windows.Data.FilterDescriptor _Filter1;  
            public Telerik.Windows.Data.FilterDescriptor Filter1  
            {  
                get 
                {  
                    return _Filter1;  
                }  
                set 
                {  
                    _Filter1 = value;  
                }  
            }  
 
            Telerik.Windows.Data.FilterDescriptor _Filter2;  
            public Telerik.Windows.Data.FilterDescriptor Filter2  
            {  
                get 
                {  
                    return _Filter2;  
                }  
                set 
                {  
                    _Filter2 = value;  
                }  
            }  
        }  
 
        public class ColumnSetting : PropertySetting  
        {  
            string _UniqueName;  
            public string UniqueName  
            {  
                get 
                {  
                    return _UniqueName;  
                }  
                set 
                {  
                    _UniqueName = value;  
                }  
            }  
 
            object _Header;  
            public object Header  
            {  
                get 
                {  
                    return _Header;  
                }  
                set 
                {  
                    _Header = value;  
                }  
            }  
 
            double? _Width;  
            public double? Width  
            {  
                get 
                {  
                    return _Width;  
                }  
                set 
                {  
                    _Width = value;  
                }  
            }  
 
            int? _DisplayIndex;  
            public int? DisplayIndex  
            {  
                get 
                {  
                    return _DisplayIndex;  
                }  
                set 
                {  
                    _DisplayIndex = value;  
                }  
            }  
        }  
 
}  
 
0
Tsvyatko
Telerik team
answered on 13 Apr 2010, 04:17 PM
Hi Brian Chung,

The first problem you have encountered is cause by the fact that GridView does not have ItemsSource set. To resolve this the second gridview need to supplied with ItemsSource (e.g. Empty ObservableCollection).

Regarding the second problem I have modified the solution to display the hierarchy content of the child rows.

About the Image column  - you can check additiona information here. I also suggest to make it work with relative resource first before pointing to external resource (since there can be permission restrictions to resolve - such as clientaccesspolicy ).

Please, let me know if this works for you.



Sincerely yours,
Tsvyatko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Brian Chung
Top achievements
Rank 1
answered on 15 Apr 2010, 09:21 AM

Hey Tsvyakto,

 

From your sample, I need to drag from a row from first grideview to the second gridview to setup a parent, then drag another row again before I can create a new instances of <Product_Terr_Line> at the second gridview to from a hierarchy content.
I am not looking for a self-referencing structure.

Can you show me how can I create new instance and having the hierarchy content with a single drag-drop?
e.g. When I drag a row from first gridview to the second gridview. New instance of <Product_Terr_line> will be created.
The information inherited from <Product_Global_Line> will be shown as Parent in the hierarchy structure of the new instance and the additional 4 attributes  of <Product_Terr_line> will be the child of the hierarchy structure, (now I put all 0 for those attributes when a new instace is created).


For the imagecolumn, I guess I know the reason I can't see it.
When I run the project with Expression Blend, the image can be shown.
I gues the reason why I can't see the image in Visual Studio is because there isn't a ".Web" project in the project that you show me.
What do you think? Is there any good way to put it back quickly?

Thank you for all the support!


Do you have any idea when will your RadControls for Silverlight 4 RC be coming production version? Thank you so much!

Brian.


0
Tsvyatko
Telerik team
answered on 20 Apr 2010, 04:44 PM
Hi Brian Chung,

The best way to create the desired structure is to use composition instead the inheritance between the two types of objects. I have created sample application demonstrating how this can be used to achieve the desired result. However, if the model requires inheritance, you can define only  the columns that needs to be displayed in Hierarchy child template - http://demos.telerik.com/silverlight/#GridView/Hierarchy/HierarchyChildTemplate

For the web project - I have created added it to the zip file as well.

The production version of the Silverlight 4 is already available in our last internal build (last Friday).

Sincerely yours,
Tsvyatko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Brian Chung
Top achievements
Rank 1
answered on 28 Apr 2010, 11:40 AM
Hello Tsvyatko,

Sorry for the late response, my last question to you is how you add the Web project back? Can you show me the steps? Thank you!

Brian
0
Accepted
Tsvyatko
Telerik team
answered on 28 Apr 2010, 02:05 PM
Hi Brian Chung,

Please check the attached video containing the steps to add web project and link the Silverlight output to it.

If you have any other questions do not hesitate to contact us.

Kind regards,
Tsvyatko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mark
Top achievements
Rank 1
answered on 27 Apr 2011, 08:26 PM
Would it be possible to convert any of the Grid to Grid drag and drop examples to current VS 2010 so they can be referenced?  There is terrific information in this thread!

Thanks,
Mark
0
Brian Chung
Top achievements
Rank 1
answered on 06 May 2011, 02:58 AM
Mark,

Zip file "186526-184974-184204-183665-183565-sl-dragbetweengrids-2.zip" is a VS2008 project but you can convert it to VS2010 project.
The conversion is simple! Once you open up the above project with VS2010, VS2010 will guide you to do a conversion.

The conversion is smooth and no error is found, thanks!


(you will find the ZIP in with messages within this thread).
0
Mark
Top achievements
Rank 1
answered on 06 May 2011, 12:21 PM
Brian,

Unfortunately I do not have the same experience when I try to upgrade it. 
In any event I am past any use from this thread personally, I just thought it would be useful to have a Grid to Grid example for others.

Mark
Tags
GridView
Asked by
Brian Chung
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Brian Chung
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Share this question
or