Disable Delete confirmation dialog

14 posts, 0 answers
  1. Cush
    Cush avatar
    88 posts
    Member since:
    Apr 2010

    Posted 28 Feb 2011 Link to this post

    Hi All

    I want to be able to disable the Delete confimation dialog box when a custom attribute is a certain value,
    I have disabled the delete command with the following script
    function schedMove(sender, args){
                    var app = args.get_appointment();
                    var attr = app.get_attributes().getAttribute('schedType');
      
      
                         if (attr == "Movement") {
                            args.set_cancel(true);
                        }
                    }

    Any help on disabling the delete confirmation would be "GREATLY" appreciated.

    Many Thanks

    Regards

    Darren
  2. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 28 Feb 2011 Link to this post

    Hi Cush,

    You can use the set_displayDeleteConfirmation() client-side property to disable the Delete Confirmation when the appointment has custom attribute with a certain value in a similar way to those that you use for Move.

    Please let me know if you have further questions.

    Regards,
    Veronica Milcheva
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. Cush
    Cush avatar
    88 posts
    Member since:
    Apr 2010

    Posted 28 Feb 2011 Link to this post

    Hi Veronica

    Thanks for the quick reply

    I have already tried your suggestion,
    I linked the function to the OnClientAppointmentDeleting event and it would not work?

    Any ideas?

    Regards

    Darren
  4. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 01 Mar 2011 Link to this post

    Hi Cush,

    I am not sure if I got your requirement. You only need to disable the Delete Confirmation of appointment when this appointment has specific custom attribute. However the property to disable the delete confirmation DisplayDeleteConfirmation can be set to the RadScheduler an not to an appointment. That's why I don't think that there's a way to disable it only for particular appointments.

    Kind regards,
    Veronica Milcheva
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  5. Cush
    Cush avatar
    88 posts
    Member since:
    Apr 2010

    Posted 01 Mar 2011 Link to this post

    Hi Veronica

    That is a shame,
    If you think of a work around i would be interested to hear it.

    Many Thanks

    Regards

    Darren
  6. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 06 Mar 2011 Link to this post

    Hello Cush,

    Please accept my apologies for the late reply.

    Actually after further investigation I found a workaround. You need to set the DisplayDeleteConfirmation property of the RadScheduler to false.
    You need to subsribe to the OnClientAppointmentDeleting event and use the following code in the handler:
    function ClientAppointmentDeletingHandler(sender, args) {
                var app = args.get_appointment();
                if (app.get_attributes().getAttribute("Delete") != null) {
                    if (confirm("Are you sure you want to delete this appointment?")) {
                        alert("now the appointment will be deleted");
                    }
                    else {
                        args.set_cancel(true);
                    }
                }
            }

    In my case I distinguish the appointments by the "Delete" custom attribute so that if this custom attribute is set to some appointment - a confirm dialog will appear when you press the "X" button. In any other cases the appointment will be deleted without prompting the user. 

    I've created a sample project to demonstrate the workaround. When you try to delete the appointment with subject "app with delete pop-up" - the needed confirm window will appear asking you whether you are sure to delete this appointment. The other appointment on the current view with subject "app without custom attributes" will be deleted directly.

    Please take a look at the project in the attached .zip file and let me know if this was helpful. 

    Greetings,
    Veronica Milcheva
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  7. Cush
    Cush avatar
    88 posts
    Member since:
    Apr 2010

    Posted 07 Mar 2011 Link to this post

    Hi Veronica

    Thanks very much for the wokaround,
    I didn't really want to lose the functionality of deleting reoccurring appointments that the Standard delete confirmation box gives you?

    Is there any way to just remove the appointment delete icon if a custom attribute is of a certain value?

    Many Thanks For your help.

    Regards

    Darren
  8. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 07 Mar 2011 Link to this post

    Hi Cush,

    Please take a look at this help article for how to hide the delete "X" button on appointments.
    You can use similar logic to my previous post to distinguish appointments and set the Css class if the custom attribute is of a certain value.

    All the best,
    Veronica Milcheva
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  9. Cush
    Cush avatar
    88 posts
    Member since:
    Apr 2010

    Posted 07 Mar 2011 Link to this post

    Hi Veronica

    Excuse my ignorance?
    If that css class is on the page it removes all the delete icons from all appointments,
    How can this be set for individual appointments ?

    Regards

    Darren
  10. Cush
    Cush avatar
    88 posts
    Member since:
    Apr 2010

    Posted 09 Mar 2011 Link to this post

    Hi Veronica

    I have been doing some digging around and I am trying to manipulate the ".rsAptDelete" Css class you suggested with an onmouseover event,
    However i cant see to get it to work?
    Am i missing something fundamental?

    function getCSSRule(ruleName, deleteFlag) {              
                         ruleName=ruleName.toLowerCase();                      
                       if (document.styleSheets) {                           
                           for (var i=0; i<document.styleSheets.length; i++) {
                           var styleSheet=document.styleSheets[i];         
                           var ii=0;                                       
                           var cssRule=false;                              
                           do {                                            
                            if (styleSheet.cssRules) {                   
                               cssRule = styleSheet.cssRules[ii];        
                            } else {                                     
                               cssRule = styleSheet.rules[ii];           
                            }                                            
                            if (cssRule)  {                              
                               if (cssRule.selectorText.toLowerCase()==ruleName) {
                                  if (deleteFlag=='delete') {             
                                     if (styleSheet.cssRules) {           
                                        styleSheet.deleteRule(ii);        
                                     } else {                             
                                        styleSheet.removeRule(ii);        
                                     }                                    
                                     return true;                         
                                  } else {                                
                                     return cssRule;                      
                                  }                                       
                               }                                          
                            }                                             
                            ii++;                                         
                         } while (cssRule)                                
                      }                                                   
                    }                                                      
                       return false;                                          
                    }
                               
                    function pageLoad() 
                    
                         var scheduler = $find('<%=RadScheduler1.ClientID %>'); 
                            scheduler.get_appointments().forEach(function(app) { 
                            app.get_element().onmouseover = function() { 
                            var attr = app.get_attributes().getAttribute('MyType');
      
                         if (attr == "Type1") {
                              
                            setCSS('none')
      
                           }else{
      
                           setCSS('inline')
                        
                          }; 
                                            }); 
                    }
                    function setCSS(args){
                        var dispIcon = getCSSRule(".rsAptDelete");
                        dispIcon.style.display = args;
                    }

    Your help as always would be most appreciated

    Best Regards

    Darren
  11. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 09 Mar 2011 Link to this post

    Hi Cush,

    Yes, you are right that apllying this - the "X" will be hidden for all the appointments. Unfortunately there is no way that I can think of with which you can hide the "X" for particular appointments. However you can stop the delete event for some appointments with specific custom attributes:

    function ClientAppointmentDeletingHandler(sender, args) {
                    var app = args.get_appointment();
                    if (app.get_attributes().getAttribute("Delete") != null)
                        app.set_allowDelete(false);
                }

    Regards,
    Veronica Milcheva
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  12. Cush
    Cush avatar
    88 posts
    Member since:
    Apr 2010

    Posted 11 Mar 2011 Link to this post

    Hi Veronica

    Thanks for getting back to me,
    I have tried this before and it still allows the defaukt delete confirmation box to load, It does the not allow the appointment to be deleteted but i can already achive this functionality by using args.set_cancel(true);

    What i would really like to do is make the appointment delete icon only visible for certain custom attribute values or only load the delete confirmation box for certain custom attribute values.

    As always thanks for your help sor far on this it is much appriciated.

    Best regards

    Darren
  13. Cush
    Cush avatar
    88 posts
    Member since:
    Apr 2010

    Posted 13 Mar 2011 Link to this post

    Hi Veronica

    I eventually found the answer to this problem HERE

    I added the following CSS to my page?

    .disableDelete

     

     

    .rsAptDelete

     

     

    {

     

     

     

    left: -4000px;

     

     

    }


    And then to the code behind
    Protected Sub RadScheduler1_AppointmentCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.AppointmentCreatedEventArgs) Handles RadScheduler1.AppointmentCreated
            Dim sType As String = e.Appointment.Attributes("sType")
      
            If sType = "Type1" Then
                e.Appointment.CssClass = "disableDelete"
            End If
        End Sub

    And bingo it works like a treat :-)

    Thanks for your help.

    Regards

    Darren
  14. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 14 Mar 2011 Link to this post

    Hello Darren,

    I'm glad that you found the solution on your own.

    Please let me know if you have further questions.

    Regards,
    Veronica Milcheva
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top