Completed
Last Updated: 30 May 2014 08:39 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 28 May 2014 15:04
Category: GridView
Type: Bug Report
0
FIX. RadGridView - Data for invisible columns should not be copied when the SelectionMode is CellSelect
Workaround: the MasterTemplate has Copy method, which allows overriding in its descendants. Thus, it is possible to modify the copied data according to the specific requirements:

public class CustomGrid : RadGridView
{
    protected override RadGridViewElement CreateGridViewElement()
    {
        return new CustomRadGridViewElement();
    }

    public override string ThemeClassName 
    {
        get
        {
            return typeof(RadGridView).FullName; 
        }
    }
}

public class CustomRadGridViewElement : RadGridViewElement
{
    protected override MasterGridViewTemplate CreateTemplate()
    {
        return new CustomMasterGridViewTemplate();
    }
    
    protected override Type ThemeEffectiveType    
    {
        get   
        {
            return typeof(RadGridViewElement);    
        }
    }
}

public class CustomMasterGridViewTemplate : MasterGridViewTemplate
{
    public override void Copy()
    {
        base.Copy();
 
        if (Clipboard.ContainsData(DataFormats.Text))
        {
            string data = Clipboard.GetData(DataFormats.Text).ToString();
     
            if (data != string.Empty)
            {
                StringBuilder sb = new StringBuilder(data);
                //modify the copied data and replace it in the clipboard
                Clipboard.SetData(DataFormats.Text, sb.ToString());
            }
        }
    }
}
0 comments