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

How to remove horizontal border in group view

7 Answers 217 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 24 Mar 2016, 12:59 PM

Hello,

I'd like to remove the horizontal border in a grid within groups (GridViewColumnGroup not GroupDescriptor).

See the attached image, the green (verticals) borders are ok the red (horizontal) borders between the cells in the group are the ones I'd like to remove. (For normal cells and cells of the summary row)

I've tried the normal formatting events, but I found no information if a cell/row is inside a group?

So is this possible at all?

--

Also the GridViewColumnGroupRow.ColumnCollection is marked deprecated, so what is the best way to do this (the ColumnNameCollection dosen't help)?

GridViewColumnGroupRow groupRow = new GridViewColumnGroupRow();
groupRow.Columns.Add(this.kMRadGridView1.Columns["column"]);

Kind regars

 

7 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 24 Mar 2016, 02:04 PM
Hi Christian,

Thank you for writing.

In this case, there is no need to check if the cell is inside a group, you can only check the cell element type. For example:
private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement is GridDataCellElement || e.CellElement is GridSummaryCellElement)
    {
        e.CellElement.BorderBoxStyle = BorderBoxStyle.FourBorders;
        e.CellElement.BorderBottomWidth = 0;
        e.CellElement.BorderTopWidth = 0;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.BorderBoxStyleProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.BorderBottomWidthProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.BorderTopWidthProperty, ValueResetFlags.Local);
    }
}

Let me know if you have additional questions.

Regards,
Dimitar
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Christian
Top achievements
Rank 1
answered on 07 Apr 2016, 06:55 AM

Hello Dimitar,

this is going in the right direction, but now there aren't any horizontal lines.

I'd like to keep the lines after the header / before the summary row and between the records (green in the screenshot)

Regards,

Christian

0
Dimitar
Telerik team
answered on 07 Apr 2016, 11:59 AM
Hi Christian,

Thank you for writing back.

You should remove the top/bottom border of the first cells only. For example:
private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement is GridSummaryCellElement || e.CellElement is GridDataCellElement )
    {
        if (e.Column.Name == "CustomerID" )
        {
            e.CellElement.BorderBoxStyle = BorderBoxStyle.FourBorders;
            e.CellElement.BorderBottomWidth = 0;
 
        }
        else if (e.Column.Name == "Phone")
        {
            e.CellElement.BorderBoxStyle = BorderBoxStyle.FourBorders;
            e.CellElement.BorderTopWidth = 0;
 
        }
        else
        {
            e.CellElement.ResetValue(LightVisualElement.BorderBoxStyleProperty, ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.BorderBottomWidthProperty, ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.BorderTopWidthProperty, ValueResetFlags.Local);
        }
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.BorderBoxStyleProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.BorderBottomWidthProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.BorderTopWidthProperty, ValueResetFlags.Local);
    }
}

Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Christian
Top achievements
Rank 1
answered on 12 Apr 2016, 09:54 AM

Hello Dimitar,

this could work, but I need a generic solution, because I have a derived grid. And I'd like to implement this as a custom property to switch it on/off.

Regards,

Christian

0
Accepted
Dimitar
Telerik team
answered on 12 Apr 2016, 11:38 AM
Hello Christian,

Thank you for writing back.

In this case, you can show the entire row border and hide the cells top and bottom borders: 
private void RadGridView1_ViewRowFormatting(object sender, RowFormattingEventArgs e)
{
    var row = e.RowElement;
    row.DrawBorder = true;
    row.BorderBoxStyle = BorderBoxStyle.FourBorders;
    row.BorderTopColor = Color.Red;
    row.BorderTopWidth = 2;
}
 
private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    e.CellElement.BorderBoxStyle = BorderBoxStyle.FourBorders;
    e.CellElement.BorderTopWidth = 0;
    e.CellElement.BorderBottomWidth = 0;
}

I hope this will be useful. 
 
Regards,
Dimitar
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Christian
Top achievements
Rank 1
answered on 27 Apr 2016, 10:36 AM

Hello Dimitar,

this kinda works, but the grid becomes slow so I've decided not to pursue this any further. Also the are drawing issues with the Hottrack / Selection (see blue vertical lines in screenshot)

Regards,

Christian

0
Dimitar
Telerik team
answered on 28 Apr 2016, 07:50 AM
Hello Christian,

Thank you for writing back.

Generally setting the styles should not have any performance impact. If you want we can investigate this, however we will neen more information and it woud be better to open a support ticked for this.

In addition you can change the border of the selcted cell with the following code:
private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (!e.CellElement.IsCurrent)
    {
        e.CellElement.BorderBoxStyle = BorderBoxStyle.FourBorders;
        e.CellElement.BorderTopWidth = 0;
        e.CellElement.BorderBottomWidth = 0;
    }
    else
    {
        e.CellElement.BorderTopWidth = 1;
        e.CellElement.BorderBottomWidth = 1;
        e.CellElement.BorderBoxStyle = BorderBoxStyle.FourBorders;
        e.CellElement.BorderTopColor = Color.Red;
        e.CellElement.BorderBottomColor = Color.Red;
    }
 
}

I hope this will be useful.

Regards,
Dimitar
Telerik
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
Christian
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Christian
Top achievements
Rank 1
Share this question
or