HtmlViewDefinition wrong header layout

2 posts, 0 answers
  1. Zerka
    Zerka avatar
    33 posts
    Member since:
    Jul 2010

    Posted 13 Mar 2012 Link to this post

    Hi,
    I have simple grid that contains 7 text columns with names column1, column2, ... column7.
    When I apply following code I got layout that is shown in file grid1.png.
    HtmlViewDefinition view = new HtmlViewDefinition();
    view.RowTemplate.Rows.Add(new RowDefinition());
    view.RowTemplate.Rows.Add(new RowDefinition());
    view.RowTemplate.Rows.Add(new RowDefinition());
     
    CellDefinition cell = new CellDefinition();
    //row1
    cell.UniqueName = "column1";
    cell.RowSpan = 1;
    cell.ColSpan = 2;
    view.RowTemplate.Rows[0].Cells.Add(cell);
     
    cell = new CellDefinition();
    cell.UniqueName = "column4";
    cell.RowSpan = 3;
    cell.ColSpan = 1;
    view.RowTemplate.Rows[0].Cells.Add(cell);
     
    cell = new CellDefinition();
    cell.UniqueName = "column5";
    cell.RowSpan = 1;
    cell.ColSpan = 1;
    view.RowTemplate.Rows[0].Cells.Add(cell);
     
    //row2
    cell = new CellDefinition();
    cell.UniqueName = "column2";
    cell.RowSpan = 2;
    cell.ColSpan = 1;
    view.RowTemplate.Rows[1].Cells.Add(cell);
     
    cell = new CellDefinition();
    cell.UniqueName = "column3";
    cell.RowSpan = 2;
    cell.ColSpan = 1;
    view.RowTemplate.Rows[1].Cells.Add(cell);
     
    cell = new CellDefinition();
    cell.UniqueName = "column6";
    cell.RowSpan = 1;
    cell.ColSpan = 1;
    view.RowTemplate.Rows[1].Cells.Add(cell);
     
    //row3
    cell = new CellDefinition();
    cell.UniqueName = "column7";
    cell.RowSpan = 1;
    cell.ColSpan = 1;
    view.RowTemplate.Rows[2].Cells.Add(cell);
     
    radGridView1.ViewDefinition = view;

    Grid2.png shows what I want to achieve.
    I am using 2011.3.11 version of Telerik.
    Thanks
  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    705 posts

    Posted 15 Mar 2012 Link to this post

    Hi Zerka,

    Thank you for writing.

    There is an issue that comes up with your particular layout. I have added this issue in our Public Issue Tracking System - PITS. You can track its progress and add your vote/comment for it on the following link - PITS Issue. Until it is resolved, the only work around I can offer you is to swap the places of the last two columns. This way the layout works correctly. Here is what I mean by swapping:
    HtmlViewDefinition view = new HtmlViewDefinition();
    view.RowTemplate.Rows.Add(new RowDefinition());
    view.RowTemplate.Rows.Add(new RowDefinition());
    view.RowTemplate.Rows.Add(new RowDefinition());
     
    CellDefinition cell = new CellDefinition();
    //row1
    cell.UniqueName = "column1";
    cell.RowSpan = 1;
    cell.ColSpan = 2;
    view.RowTemplate.Rows[0].Cells.Add(cell);
     
    cell = new CellDefinition();
    cell.UniqueName = "column5";
    cell.RowSpan = 1;
    cell.ColSpan = 1;
    view.RowTemplate.Rows[0].Cells.Add(cell);
     
    cell = new CellDefinition();
    cell.UniqueName = "column4";
    cell.RowSpan = 3;
    cell.ColSpan = 1;
    view.RowTemplate.Rows[0].Cells.Add(cell);
     
    //row2
    cell = new CellDefinition();
    cell.UniqueName = "column2";
    cell.RowSpan = 2;
    cell.ColSpan = 1;
    view.RowTemplate.Rows[1].Cells.Add(cell);
     
    cell = new CellDefinition();
    cell.UniqueName = "column3";
    cell.RowSpan = 2;
    cell.ColSpan = 1;
    view.RowTemplate.Rows[1].Cells.Add(cell);
     
    cell = new CellDefinition();
    cell.UniqueName = "column6";
    cell.RowSpan = 1;
    cell.ColSpan = 1;
    view.RowTemplate.Rows[1].Cells.Add(cell);
     
    //row3
    cell = new CellDefinition();
    cell.UniqueName = "column7";
    cell.RowSpan = 1;
    cell.ColSpan = 1;
    view.RowTemplate.Rows[2].Cells.Add(cell);
     
    radGridView1.ViewDefinition = view;

    I have also updated your Telerik points for reporting this issue.

    I hope this will help. Should you have further questions, I would be glad to help.

    All the best,
    Ivan Petrov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top