This is a migrated thread and some comments may be shown as answers.
GridView: CheckBox visible and enabled conditionally.
1 Answer 3 Views
This is a migrated thread and some comments may be shown as answers.
Eusebio
Top achievements
Rank 1
Eusebio asked on 12 Nov 2020, 08:48 AM

Hi,

 

In some rows of the grid I need the CHECKBOX to be visible and enabled. How do I do that?

I attach an image.

 

Best regards.

1 Answer, 1 is accepted

Sort by
0
Nadya
Telerik team
answered on 12 Nov 2020, 11:46 AM

Hello, Eusebio,

I suppose that you are using GridViewCheckBoxColumn in the grid. By default, the checkboxes are always visible. If you want to have checkboxes visible only for specific rows, you should handle the CellFormatting event and manage RadCheckBoxEditorElement's Visibility property:

private void RadGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    GridCheckBoxCellElement cell = e.CellElement as GridCheckBoxCellElement;
    if (cell != null)
    {
        RadCheckBoxEditorElement editorElement = (cell.Editor as RadCheckBoxEditor).EditorElement as RadCheckBoxEditorElement;
        if (e.RowIndex == 0 || e.RowIndex == 1)
        {
            editorElement.Visibility = ElementVisibility.Visible;
        }
        else
        {
            editorElement.Visibility = ElementVisibility.Hidden;
        }
    }
}

I hope this helps. Should you have further questions please let me know.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Asked by
Eusebio
Top achievements
Rank 1
Answers by
Nadya
Telerik team
Share this question
or