So if I wanted to modify a value (example: Visible = Collapse) in this highlighted element of RadScheduler. How do I do that?
Dess | Tech Support Engineer, Principal
Telerik team
commented on 09 Jan 2023, 07:10 AM
Hello, Thomas,
You have access to the SchedulerHeaderCellElement in the CellFormatting event. However, note that the visual cell elements are being reused during operations like scrolling. Hiding the cells is not recommended. That is why I would kindly ask you to provide more details about the exact goal that you are trying to achieve? Thus, we would get better understanding of the precise case and think about an appropriate solution. Thank you in advance. I am looking forward to your reply.
Here is my grid (guide). The areas in purple are the elements I am trying to change. I know they are in different classes. I am trying to determine which classes so I can modify them in the cell format event. I have posed my current cell format method below.
Note that the Font creation is a time-consuming operation and the CellFormatting event is expected to be fired many times. That is why it is recommended to create the fonts outside the CellFormatting event handler and just use the variables when formatting the cells.
As to the question at hand, please have in mind that the SchedulerHeaderCellElement and the SchedulerResourceHeaderCellElement are derivatives of SchedulerCellElement. Hence, all the customization logic for these cell types should be executed before the default condition. It is also necessary to use if-else-if-else structure instead of only if statements because thus several if conditions may be matched and style settings applied to undesired elements. Last, but not least, scheduler cell elements are created only for currently visible cells and are being reused during operations like scrolling. In order to prevent applying the formatting to other cell elements (because of the cell reuse), all customization should be reset for the rest of the cell elements. In other words, each "if" statement should have its "else" clause for resetting the previously applied styles settings like it is demonstrated in the help article: https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formatting-cells
Thank you. I have moved the create fonts outside the CellFormatting event handler as suggested. I corrected the if only statements to the if-else-if-else structure.
Hello, Thomas,
You have access to the SchedulerHeaderCellElement in the CellFormatting event. However, note that the visual cell elements are being reused during operations like scrolling. Hiding the cells is not recommended. That is why I would kindly ask you to provide more details about the exact goal that you are trying to achieve? Thus, we would get better understanding of the precise case and think about an appropriate solution. Thank you in advance. I am looking forward to your reply.
Here is my grid (guide). The areas in purple are the elements I am trying to change. I know they are in different classes. I am trying to determine which classes so I can modify them in the cell format event. I have posed my current cell format method below.
Note that the Font creation is a time-consuming operation and the CellFormatting event is expected to be fired many times. That is why it is recommended to create the fonts outside the CellFormatting event handler and just use the variables when formatting the cells.
As to the question at hand, please have in mind that the SchedulerHeaderCellElement and the SchedulerResourceHeaderCellElement are derivatives of SchedulerCellElement. Hence, all the customization logic for these cell types should be executed before the default condition. It is also necessary to use if-else-if-else structure instead of only if statements because thus several if conditions may be matched and style settings applied to undesired elements. Last, but not least, scheduler cell elements are created only for currently visible cells and are being reused during operations like scrolling. In order to prevent applying the formatting to other cell elements (because of the cell reuse), all customization should be reset for the rest of the cell elements. In other words, each "if" statement should have its "else" clause for resetting the previously applied styles settings like it is demonstrated in the help article:
https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formatting-cells
I hope this information helps.