White space between columns

4 posts, 0 answers
  1. Sergei
    Sergei avatar
    10 posts
    Member since:
    Jun 2015

    Posted 17 Nov 2016 Link to this post

    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 ).

  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    416 posts

    Posted 21 Nov 2016 Link to this post

    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.
  3. Sergei
    Sergei avatar
    10 posts
    Member since:
    Jun 2015

    Posted 29 Nov 2016 in reply to Stefan Nenchev Link to this post

    We use properties binding, and applying of the changes in the columns' appearance happens before data loads.
  4. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    416 posts

    Posted 29 Nov 2016 Link to this post

    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.
Back to Top