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

How to disable edit, add new, delete items?

8 Answers 248 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
thuy
Top achievements
Rank 1
thuy asked on 12 May 2015, 06:05 AM

Hello Support.

May you please tell me how I can disable add new, edit, delete items both in text view and graphical view of GanttView?

Thanks & Regards,

Thuy

8 Answers, 1 is accepted

Sort by
0
thuy
Top achievements
Rank 1
answered on 12 May 2015, 06:07 AM
I still want the control is enable. just disable add new, edit and delete in ganttView
0
Ralitsa
Telerik team
answered on 12 May 2015, 08:02 AM
Hi Thuy,

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.

 
0
thuy
Top achievements
Rank 1
answered on 13 May 2015, 03:27 AM

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

0
Ralitsa
Telerik team
answered on 13 May 2015, 06:38 AM
HI 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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
thuy
Top achievements
Rank 1
answered on 14 May 2015, 02:56 AM

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 

0
Ralitsa
Telerik team
answered on 15 May 2015, 07:24 AM
Hi Thuy,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
thuy
Top achievements
Rank 1
answered on 20 May 2015, 01:00 AM

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.

 

 

 

 

0
Ralitsa
Telerik team
answered on 21 May 2015, 01:35 PM
Hi Thuy,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GanttView
Asked by
thuy
Top achievements
Rank 1
Answers by
thuy
Top achievements
Rank 1
Ralitsa
Telerik team
Share this question
or