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

Cell borders disappear for GridViewCommandColumn

2 Answers 223 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Per
Top achievements
Rank 1
Per asked on 11 Jan 2017, 10:04 AM

Hi,

I have a GridViewCommandColumn with buttons that are not always visible (using e.CellElement.Visibility = ElementVisibility.Hidden). When they are not visible the border lines around the cell disappear (see image 1).

I tried to fix this using EnableCustomDrawing=True and subscribing to the CellPaint event and draw the border manually, but this does not seem to work. In fact the CellPaint event seem to happen BEFORE the buttons is drawn. I came to this conclusion by drawing a black border around all cells, and got the result in image 2.

How can I fix this missing border problem?

/Per

2 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 11 Jan 2017, 12:40 PM
Hi Per,

Thank you for writing.

You can directly access the button element and set its Visibility property. A suitable place for performing this task is the handler of the CellFormatting event. Please check my code snippet below: 
private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    GridCommandCellElement commandCell = e.CellElement as GridCommandCellElement;
    if (commandCell != null)
    {
        if (e.RowIndex % 2 == 0)
        {
            commandCell.CommandButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
        }
        else
        {
            commandCell.CommandButton.ResetValue(LightVisualElement.VisibilityProperty, Telerik.WinControls.ValueResetFlags.Local);
        }
         
    }
}

I am also sending you a screenshot showing the result on my end.

I hope this helps. Please let me know if you need further assistance.

Regards,
Hristo
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Per
Top achievements
Rank 1
answered on 11 Jan 2017, 01:31 PM

Thank you!

Calling ResetValue when the button is visible solved the problem...

/Per

Tags
GridView
Asked by
Per
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Per
Top achievements
Rank 1
Share this question
or