8 Answers, 1 is accepted
Thank you for contacting us.
If you want to hide the default context menu, you can subscribe to the ContextMenuOpening event and cancel it. Here is the code snippet:
void
radGanttView1_ContextMenuOpening(
object
sender, GanttViewContextMenuOpeningEventArgs e)
{
e.Cancel =
true
;
}
You can set the Enabled property to false and disable a concrete menu item from the default context menu:
void
radGanttView1_ContextMenuOpening(
object
sender, GanttViewContextMenuOpeningEventArgs e)
{
GanttViewDefaultContextMenu menu = e.Menu
as
GanttViewDefaultContextMenu;
menu.DeleteMenuItem.Enabled =
false
;
}
More information about context menu of RadGanttView can be found on the following link from documentation: GanttView >> Context Menu >> Modifying context menu.
I hope this will help you. Let me know if you have any other questions.
Regards,
Ralitsa
Telerik
See What's Next in App Development. Register for TelerikNEXT.
Thank Ralitsa for your quick reply.
However the answer is not what I really want. End user can edit a task in ganttview by resizing it
As you know, GanttView have Text element and Graphical element. I can disable edit in textview. But for graphicalview, I can't disable resizing of a task.
Thanks & Regards,
Thuy
Thank you for your reply.
You can subscribe to the PreviewDragStart event and cancel moving or resizing of tasks in the GanttViewGraphicalViewElement. Here is the code snippet:
//subscribe to the PreviewDragStart event
this
.radGanttView1.DragDropService.PreviewDragStart += DragDropService_PreviewDragStart;
//handle the PreviewDragStart event
void
DragDropService_PreviewDragStart(
object
sender, PreviewDragStartEventArgs e)
{
e.CanStart =
false
;
}
I hope this will help. Do not hesitate to write back with further questions.
Regards,
Ralitsa
Telerik
Thank Ralitsa for your quick reply
However, it doesn't work. I still can resizing graphicTask Item as this link
http://www.telerik.com/help/winforms/ganttview-editing-editing-graphicalview.html
Thanks
I am sorry if I misunderstood your requirements initially. I suggest you to set the ReadOnly property to true which will automatically hide the context menu, disable resizing, drag and drop and editing features of tasks.
If you want to disable editing, deleting and adding of specific task, you can use the following code snippets to customize it:
- disable the default context menu:
void
radGanttView2_ContextMenuOpening(
object
sender, GanttViewContextMenuOpeningEventArgs e)
{
e.Cancel =
true
;
}
- disable drag and drop of tasks in GraphicalView:
this
.radGanttView1.DragDropService.PreviewDragStart += DragDropService_PreviewDragStart;
void
DragDropService_PreviewDragStart(
object
sender, Telerik.WinControls.PreviewDragStartEventArgs e)
{
e.CanStart =
false
;
}
- disable resizing of tasks:
this
.radGanttView2.AllowSummaryEditing =
false
;
this
.radGanttView2.GraphicalViewItemFormatting += radGanttView2_GraphicalViewItemFormatting;
void
radGanttView2_GraphicalViewItemFormatting(
object
sender, GanttViewGraphicalViewItemFormattingEventArgs e)
{
e.Item.ReadOnly =
true
;
}
- disable adding of links:
void
radGanttView2_LinkAdding(
object
sender, GanttViewLinkAddingEventArgs e)
{
e.Cancel =
true
;
}
In the attachments you can find a sample demo which demonstrates the both approaches.
Hope this will help you. Let me know if you have any another questions.
Regards,
Ralitsa
Telerik
Hi Ralitsa,
Thanks for your reply with detailed instruction.
The option with ReadOnly looks like the simplest one but actually I can create links between tasks after setting ReadOnly property to true.
We are still using the version 2014.3.1202.40. Can you advise it the issue was already fixed in version 2015.1?
Handling AddLinking event as suggested above can prevent adding links. Therefore, I will go with that approach.
Thank you for your reply.
I can confirm that this is an issue with RadGanttView and is reproducible with our latest version Q1 2015 SP1(2015.1.331). I have logged in our Feedback Portal. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - FIX. RadGanttView - the user can add links when the RadGanttView is in read only mode.
I can suggest you to disable adding of links as a workaround:
void
radGanttView2_LinkAdding(
object
sender, GanttViewLinkAddingEventArgs e)
{
e.Cancel =
true
;
}
I have also updated your Telerik Points.
Let me know if you have any other questions.
Regards,
Ralitsa
Telerik