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

White space between columns

3 Answers 72 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eugene
Top achievements
Rank 1
Eugene asked on 17 Nov 2016, 08:27 AM

Hello!
I'm having an issue with empty space between two columns, when the column between them is hidden.
I changed the order and width of columns.
This simple project demonstrates the problem (https://1drv.ms/u/s!AvjI7FUHDKc8bN-uiEV4lHRS67s ).

3 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 21 Nov 2016, 09:43 AM
Hello Sergei,

You can avoid the behavior by applying the changes in the columns'  appearance in the DataLoaded event of the RadGridView instead of the AutoGeneratingColumns:

private void gridView_DataLoaded(object sender, EventArgs e)
       {
           foreach (var col in gridView.Columns)
           {
               if (col.UniqueName == "Name")
               {
                   col.Width = 300;
                   col.IsVisible = true;
                   col.DisplayIndex = 2;
               }
               if (col.UniqueName == "Established")
               {
                   col.IsVisible = false;
                   col.DisplayIndex = 1;
               }
               if (col.UniqueName == "StadiumCapacity")
               {
                   col.IsVisible = true;
                   col.DisplayIndex = 0;
               }
           }
       }

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Eugene
Top achievements
Rank 1
answered on 29 Nov 2016, 08:59 AM
We use properties binding, and applying of the changes in the columns' appearance happens before data loads.
0
Stefan Nenchev
Telerik team
answered on 29 Nov 2016, 11:30 AM
Hello Sergei,

Applying the logic through the Dispatcher also works fine:

private void gridView_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
      {
          Dispatcher.BeginInvoke((Action)(() =>
          {
              if (e.Column.UniqueName == "Name")
              {
                  e.Column.Width = 100;
                  e.Column.IsVisible = true;
                  e.Column.DisplayIndex = 2;
              }
              if (e.Column.UniqueName == "Established")
              {
                  e.Column.IsVisible = false;
                  e.Column.DisplayIndex = 1;
              }
              if (e.Column.UniqueName == "StadiumCapacity")
              {
                  e.Column.IsVisible = true;
                  e.Column.DisplayIndex = 0;
              }
          }));
      }

I hope it will be suitable for you as well.

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Eugene
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Eugene
Top achievements
Rank 1
Share this question
or