3 Answers, 1 is accepted
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.
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
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.