Completed
Last Updated: 07 Dec 2015 10:53 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 01 May 2014 07:11
Category: GridView
Type: Bug Report
0
FIX. RadGridView - setting the DataSource property does not generate columns after some manually added columns were deleted via the Property Builder
To reproduce:
-Add a RadGridView and use the following code snippet:

 public Form1()
 {
     InitializeComponent();

      //add GridViewCheckBoxColumn with DataType to BOOL
     GridViewCheckBoxColumn autoTestingselectColumn = new GridViewCheckBoxColumn();
     autoTestingselectColumn.DataType = typeof(bool);
     autoTestingselectColumn.Name = "AutomatedTestingSelectColumn";
     autoTestingselectColumn.FieldName = "AutomatedTestingSelectColumn";
     autoTestingselectColumn.HeaderText = "Automated Testing Select";
     radGridView1.MasterTemplate.Columns.Add(autoTestingselectColumn);

     //add GridViewCheckBoxColumn with DataType to INT
     GridViewCheckBoxColumn startTestingColumn = new GridViewCheckBoxColumn();
     startTestingColumn.DataType = typeof(int);
     startTestingColumn.Name = "StartTestingColumn";
     startTestingColumn.FieldName = "StartTestingColumn";
     startTestingColumn.HeaderText = "StartTesting";
     radGridView1.MasterTemplate.Columns.Add(startTestingColumn);

     List<Item> items = new List<Item>();
     for (int i = 0; i < 5; i++)
     {
         items.Add(new Item(Guid.NewGuid().ToString(),"Name"+i));
     }

     this.radGridView1.DataSource = items;
      //set the AutoSizeColumnsMode property to Fill
     this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
 }

 public class Item
 {
     public string UniqueIdentifier { get; set; }
     public string Name { get; set; }
     public Item(string uniqueIdentifier, string name)
     {
         this.UniqueIdentifier = uniqueIdentifier;
         this.Name = name;
     }
 }

-Run the project. As a result 4 columns are displayed: two programmatically added and two coming from the data source.
-Now open the Property Builder at design time and add a GridViewCheckBoxColumn.
-Run the project. As a result, 5 columns are displayed: one added at design time, two programmatically added, two coming from the data source.
-Open the Property Builder again and delete the GridViewCheckBoxColumn.
-Run the project. You will notice that only two columns are displayed. The columns, coming from the data source are not generated.

Workaround: delete columns using the Columns collection at design time, instead of using the property Builder.
0 comments