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

RadScheduler disable Drag'n'Drop

8 Answers 180 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steffen
Top achievements
Rank 1
Veteran
Steffen asked on 08 Mar 2010, 02:12 PM
Hi,

it seems the RadScheduler's drag 'n' drop behaviour has changed.
Inside my AppointmentTemplates for the Day-View I have a lot of "custom" drag 'n' drop functionality (and scrollviewers) which was no problem before.
But with the beta the RadGridView's own Drag'n'Drop starts immediately and tries to move the appointment.

How can I disable the drag'n'drop? Or maybe there is another solution.

Best Regards
Steffen

8 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 09 Mar 2010, 09:23 AM
Hi Steffen,

Thank you for contacting us.

Could you please send us sample running project or the code for the AppointmentTemplate to see what the problems are?

As for disabling drag and drop functionality - there is 2 ways to do that:

1.Set the IsReadOnly property of scheduler to true.
2.Hook on the AppointmentEditing event and set e.Cancel = true in its event handler.

Regards,
Rosi
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Steffen
Top achievements
Rank 1
Veteran
answered on 09 Mar 2010, 11:50 AM
Hi Rosi,

thank you for suggesting these workarounds. Canceling the Edit-event behaves a little different from setting IsReadonly to true. While my custom Drag'n'Drop works in both cases, canceling the Edit-event makes the AppointmentTemplate's ScrollViewer's "undraggable" (clicking works).

Here is a short repro (try to scroll the Hugo's):
  public partial class Window1 : Window 
    { 
        public Window1() 
        { 
            InitializeComponent(); 
 
            ObservableCollection<MyAppointment> col = new ObservableCollection<MyAppointment>(); 
 
            MyAppointment a = new MyAppointment(); 
            a.Start = DateTime.Now; 
            a.End = a.Start.AddHours(1); 
 
            for (int i = 0; i < 100; ++i) a.Persons.Add(new Person() { Name = "Hugo" }); 
            
            col.Add(a); 
 
            scheduler.AppointmentsSource = col; 
 
            scheduler.ViewMode = Telerik.Windows.Controls.SchedulerViewMode.Day; 
            scheduler.SelectedAppointment = a; 
        } 
 
        private void PersonListBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
        { 
            //custom drag'n'drop code goes here.... 
 
            //the appointment shoudn't move 
        } 
    } 
 
    public class MyAppointment : AppointmentBase 
    { 
        public override IAppointment Copy() 
        { 
            throw new NotImplementedException(); 
        } 
 
        private ObservableCollection<Person> m_persons = new ObservableCollection<Person>(); 
        public ObservableCollection<Person> Persons 
        { 
            get { return m_persons; } 
            set { m_persons = value; } 
        } 
    } 
 
    public class Person 
    { 
        public string Name { getset; } 
    } 

<Window x:Class="RadSchedulerDragDrop.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    Title="Window1" Height="600" Width="600"
    <Window.Resources> 
        <DataTemplate x:Key="AppointmentTemplate"
            <ListBox ItemsSource="{Binding Path=Occurrence.Appointment.Persons}" ScrollViewer.VerticalScrollBarVisibility="Visible" PreviewMouseLeftButtonDown="PersonListBox_PreviewMouseLeftButtonDown"
                <ListBox.ItemsPanel> 
                    <ItemsPanelTemplate> 
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left"/> 
                    </ItemsPanelTemplate> 
                </ListBox.ItemsPanel> 
                 
                <ListBox.ItemTemplate> 
                    <DataTemplate> 
                        <TextBlock Width="100" Text="{Binding Path=Name}"/> 
                    </DataTemplate> 
                </ListBox.ItemTemplate> 
            </ListBox> 
        </DataTemplate> 
         
    </Window.Resources> 
    <Grid> 
        <telerik:RadScheduler Name="scheduler" OpenModalDialogs="False" AppointmentTemplate="{StaticResource AppointmentTemplate}"
             
        </telerik:RadScheduler> 
    </Grid> 
</Window> 

 Best Regards
Steffen

0
Steffen
Top achievements
Rank 1
Veteran
answered on 11 Mar 2010, 01:48 PM
Hi,

with the new release Q1_2010 setting scheduler.IsReadonly=true also sets the appointment-templates readonly(didn't happen with the beta)  - so I have to cancel the edit-event which makes the appointment's Srollviewer "undraggable" (if dragging enough it starts jumping).
Maybe there is another solution to avoid the scheduler's drag'n'drop-functionality? Maybe by modifying my custom theme(HitTestVisibility or something like that).


Best Regards
Steffen
0
Rosi
Telerik team
answered on 11 Mar 2010, 03:42 PM
Hi Steffen,

I modified the code that you provided illustrating how you can achieve the goal insted of using the IsReadOnly property. Please add the code in yellow to your application.

<DataTemplate x:Key="AppointmentTemplate">
            <ListBox  Loaded="ListBox_Loaded" ItemsSource="{Binding Path=Occurrence.Appointment.Resources}" ScrollViewer.VerticalScrollBarVisibility="Visible" >
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left"/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Width="100" Text="{Binding Path=ResourceName}"/>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </DataTemplate>


private void ListBox_Loaded(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.ListBox list = sender as System.Windows.Controls.ListBox;
            AppointmentItem item = list.ParentOfType<AppointmentItem>();
            RadDragAndDropManager.SetAllowDrag(item, false);
        }

Hope this helps.

Kind regards,
Rosi
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Steffen
Top achievements
Rank 1
Veteran
answered on 11 Mar 2010, 05:54 PM
Hi,

thank you so much. This is exactly what I needed!

There is just one little thing left: How can I get rid of the Hand-Cursor?
It's still there and I need my own DragOver-Cursors to show up again, so people can see what they can(or can't) drag inside my appointment.

Best Regards
Steffen
0
Accepted
Rosi
Telerik team
answered on 12 Mar 2010, 08:28 AM
Hi Steffen,

I suggest you just set the Cursor property of the ListBox to Arrow:

<ListBox Cursor="Arrow" .../>


Regards,
Rosi
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Jose Granja
Top achievements
Rank 1
answered on 13 Apr 2010, 02:47 PM
Hi,

I don't know why I'm getting disabled = "disabled" in my appointment template! Crazy, I don't know what I touched that I started looking like this.... Is there any reason why the appointmentTemplate can have disabled="disabled" ???? I don't know where it's coming from

regards.

jose
0
Teodor
Telerik team
answered on 15 Apr 2010, 03:38 PM
Hello Jose Granja,

Thank you for contacting us.

Could you please send us your project or a sample app demonstrating that? Thus we can be more productive in finding the right solution for you.

Thank you in advance.

Sincerely yours,
Teodor
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
Steffen
Top achievements
Rank 1
Veteran
Answers by
Rosi
Telerik team
Steffen
Top achievements
Rank 1
Veteran
Jose Granja
Top achievements
Rank 1
Teodor
Telerik team
Share this question
or