how to prevent saving Appointment before i finished some custom logic

8 posts, 0 answers
  1. Yi
    Yi avatar
    15 posts
    Member since:
    Jul 2013

    Posted 26 Nov 2013 Link to this post

    because i binding the appointmentsource to DB.before click ok button,i should do some business rule.
    how can i do 
  2. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 28 Nov 2013 Link to this post

    Hi Yi,

    What I can suggest you is that you handle the DialogClosing of the ScheduleView. The event is fired when the EditAppointmentDialog is about to close and before the AppointmentSaving is fired. For more information about the ScheduleView events you can check the following article from our online help documentation:
    http://www.telerik.com/help/silverlight/radscheduleview-events-overview.html

    Hope this helps.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Yi
    Yi avatar
    15 posts
    Member since:
    Jul 2013

    Posted 28 Nov 2013 Link to this post

    sorry that i have used WCF RIA Services do my logic.
    how i use this in this event base on asynchronous operation .
  5. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 29 Nov 2013 Link to this post

    Hi Yi,

    I understand now. What I can suggest you is to extract and modify the default EditAppointmentDialogTemplate and replace the Ok button with custom one bound to a Command in the ViewModel. This way will be able to execute the custom logic in that Command and when completed you can manually confirm the dialog.
    The button should look as follows, note that you will also need to pass the button it self as a parameter:

    <telerik:RadButton Content="Ok"
                    DataContext="{StaticResource ViewModel}"
                    Command="{Binding ButtonClick}"
                    CommandParameter="{Binding RelativeSource={RelativeSource Self}}" />
     
    And the command:

    private void OnButtonClick(object obj)
    {
        // do custom logic here and confirm the dialog when needed with the command below
        WindowCommands.Confirm.Execute(null, obj as RadButton);
    }

    As for the custom dialog you can check the following article from our online help documentation:
    http://www.telerik.com/help/wpf/radscheduleview-features-custom-dialogs.html

    Hope this helps.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Yi
    Yi avatar
    15 posts
    Member since:
    Jul 2013

    Posted 01 Dec 2013 Link to this post

    can i use it in default theme?
  7. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 02 Dec 2013 Link to this post

    Hello Yi,

    Yes, of course. You just need to extract the default ControlTemplate of the EditAppointmentDialog from the OfficeBlack theme. The needed XAML file is located in the Themes.Implicit folder which is inside of the installation folder of the controls.

    If you have any further questions, let us know.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  8. Yi
    Yi avatar
    15 posts
    Member since:
    Jul 2013

    Posted 02 Dec 2013 Link to this post

     in this command i found i can't use this datacontext of this dialog.i want to use some properties of creating appointment.like starttime,endtime
  9. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 04 Dec 2013 Link to this post

    Hello Yi,

    What I can suggest you in this case is to pass the Grid which hold the Button as CommandParameter. This way you will have the ViewModel of the Grid as well as the Button which is inside of it (you will to name the Button in this case). The Button in the EditAppointmentDialog ControlTemplate should look like this (I have passed the Grid with name Details as a parameter):

    <telerik:RadButton x:Name="CustomButton"
                         Margin="2" MinWidth="84"
                         Content="Ok" DataContext="{StaticResource ViewModel}"
                         Command="{Binding ButtonClick}"
                         CommandParameter="{Binding ElementName=Details}" />

    And the Command in the ViewModel should look like shown below:
    private void OnButtonClick(object obj)
    {
        // Get the AppointmentDialogViewModel
        var grid = obj as Grid;
        var vm = grid.DataContext as AppointmentDialogViewModel;           
        // Do the additional logic here
        // ...
        // Confirm the dialog below
        var button = grid.FindName("CustomButton") as RadButton;
        WindowCommands.Confirm.Execute(null, button);
    }

    Hope this works for you.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
DevCraft banner