How to print an appointment?

4 posts, 0 answers
  1. David Eisner
    David Eisner avatar
    16 posts
    Member since:
    Jun 2007

    Posted 07 Dec 2008 Link to this post

    Does anyone know how to programmtically print an appointment from the AdvacnedForm? In other words, I simply want to know how to print appointment details while editing/inserting. There has to be a better way than just printing from the browser...
  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 09 Dec 2008 Link to this post

    Hi David,

    Currently, RadScheduler does not provide any special printing capabilities and the only way to print it is throught the browser. We will consider imlementing such functionality in the future.


    Regards,
    Peter
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David Eisner
    David Eisner avatar
    16 posts
    Member since:
    Jun 2007

    Posted 14 Dec 2008 Link to this post

    No worries, I created a solution that you may wish to consider.

    Steps to create an appointment printing function (caveat: must be using AdvancedTemplates).

    1. In both the ButtonsPanel in the custom controls AdvancedEditForm.ascx and 
        AdvancedInsertForm.ascx, add the following code just before the
        UpdateButton reference:

     

    <a href="javascript:PrintAppointment();" id="PrintButton" class="rsAdvEditCancel"><span>Print</span></a>

     


    2. Add the JavaScript function in the below scruot to the page containing the primary RadScheduler control:

       // print selected appointment
        function PrintAppointment() {

            // retrieve scheduler object and current appointment details
            var radscheduler = $find('<%= RadScheduler1.ClientID%>');
            var appt = radscheduler.get_currentAppointment();
            var subject = appt.get_subject();
            var attrib = appt.get_attributes();
            var description = attrib.getAttribute('Description');       // get optional attribute(s)

            if (!subject || subject == '')
                return;
            if (!description || description == '')
                return;

            // handle printing
            gAutoPrint = true;

            var html = '<html>\n<head>\n';

            html += '<title>Appointment</title>\n';
            html += '<style type=\'text/css\'>\n';
            html += 'body {\n';
            html += 'font-family: Arial, Helvetica, sans-serif;\n';
            html += 'font-size: 9pt;\n';
            html += '}\n';
            html += '</style>\n';

            html += '</head>\n<body bgcolor=\'#FFFFFF\'>\n';

            html += subject + '\n\n';
            html += description;

            html += '\n</body>\n</html>';

            html = html.replace(/\n/gi, '<br />');

            var printWin = window.open("", "printAppointment");
            printWin.document.open();
            printWin.document.write(html);
            printWin.document.close();
            if (gAutoPrint) {
                printWin.print();
                printWin.close();
            } else {
                alert("Sorry, appointment printing is not supported.");
            }
        }





    Presto, you are done.

    Couple of implementation notes:
    1. The only real problem with the scripting method I came up with is that if a user edits the text box(es) that comprise the appointment, the printing function isn't aware and prints the contents of the fields that were loaded. Basically, we need to implement a method that indicates the text boxes are "dirty" and possibly warn the user to Save the appointment prior to printing.
    2. In the above script function, make sure to customize as you see fit including adding or removing attributes/resources to the printed HTML

  5. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 15 Dec 2008 Link to this post

    Hi David,

    Thank you for posting your workaround. I have forwarded it to our developers.

    Sincerely yours,
    Peter
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top