Hi,
I have a RadGridView that has a checkbox column. When adding a new row (using AddNew method, if that matters), depending on some condition, I want to hide the checkbox of that row. It seemed simple enough, but I couldn't figure it out. Am I missing something obvious?
Please help. Thanks.
Andy
I have a RadGridView that has a checkbox column. When adding a new row (using AddNew method, if that matters), depending on some condition, I want to hide the checkbox of that row. It seemed simple enough, but I couldn't figure it out. Am I missing something obvious?
Please help. Thanks.
Andy
8 Answers, 1 is accepted
0
Richard Slade
Top achievements
Rank 2
answered on 28 Jan 2011, 10:03 AM
Hello Andy,
You can hide the checkbox using the cell formatting event. Please have a look at my answer in this forum post which should help you to do this. If yo uneed further help though please let me know
Thanks
Richard
You can hide the checkbox using the cell formatting event. Please have a look at my answer in this forum post which should help you to do this. If yo uneed further help though please let me know
Thanks
Richard
0
Andy
Top achievements
Rank 1
answered on 28 Jan 2011, 07:06 PM
Hi Richard,
That worked, but it introduced an unwanted effect: the top border of the collapsed cell disappeared. Please see the attached image. Is there a workaround to this problem?
Thanks,
Andy
That worked, but it introduced an unwanted effect: the top border of the collapsed cell disappeared. Please see the attached image. Is there a workaround to this problem?
Thanks,
Andy
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 28 Jan 2011, 09:19 PM
Hi Andy,
Yes, there is a better solution actually than the one I originally proposed.
It's just to make the checkmark itself collpased rather than the whole cell.
Let me know if that helps
Richard
Yes, there is a better solution actually than the one I originally proposed.
It's just to make the checkmark itself collpased rather than the whole cell.
Private Sub RadGridView1_CellFormatting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.CellFormatting If TypeOf e.CellElement Is GridCheckBoxCellElement Then ' If its a Checkbox cell If e.CellElement.RowInfo.Cells("Id").Value IsNot Nothing Then ' and the Id column (for exmaple) is not null If Convert.ToInt32(e.CellElement.RowInfo.Cells("Id").Value) = 1 Then ' If the Id is 1 CType(e.CellElement.Children(0), RadCheckBoxEditorElement).Checkmark.Visibility = ElementVisibility.Collapsed End If End If End IfEnd SubLet me know if that helps
Richard
0
Andy
Top achievements
Rank 1
answered on 28 Jan 2011, 09:41 PM
Hi Richard,
Your new method works well. Thank you for the quick response.
Andy
Your new method works well. Thank you for the quick response.
Andy
0
Richard Slade
Top achievements
Rank 2
answered on 28 Jan 2011, 09:44 PM
No problem Andy. Glad I could help
All the best
Richard
All the best
Richard
0
Hello,
Richard's solution is fine. I would like only to point out how to use the API of the GridCheckBoxCellElement to achieve this result:
Best regards,
Alexander
the Telerik team
Richard's solution is fine. I would like only to point out how to use the API of the GridCheckBoxCellElement to achieve this result:
private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e){ GridCheckBoxCellElement cell = e.CellElement as GridCheckBoxCellElement; if (cell != null) { RadCheckBoxEditor editor = cell.Editor as RadCheckBoxEditor; editor.EditorElement.Visibility = ElementVisibility.Collapsed; }}Best regards,
Alexander
the Telerik team
0
Michael
Top achievements
Rank 1
answered on 28 Apr 2017, 05:44 AM
This solution works great. I've been able to do the same with a GridCommandCellElement, but I can't figure out how to hide a GridDataCellElement. I have a GridViewDecimalColumn and GridViewComboboxColumn in my grid and I want to show or hide the content based on some criteria. Cell.Editor seem to be a null in both cases.
0
Hello Michael,
Thank you for writing.
The Editor property is specific to the GridCheckBoxCellElement. For other data cells, you can still handle the CellFormatting event and set a certain property to change the visual appearance of the cell. Because of the virtualization of the control, please do not forget to add an else clause and reset the properties. Additional information is available here: Formatting Cells.
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo
Telerik by Progress
Thank you for writing.
The Editor property is specific to the GridCheckBoxCellElement. For other data cells, you can still handle the CellFormatting event and set a certain property to change the visual appearance of the cell. Because of the virtualization of the control, please do not forget to add an else clause and reset the properties. Additional information is available here: Formatting Cells.
I hope this helps. Should you have further questions please do not hesitate to write back.
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.
