Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created July 18, 2018 11:42
Show Gist options
  • Save bjoerntx/012649afc127e9498264f4607e4d51a3 to your computer and use it in GitHub Desktop.
Save bjoerntx/012649afc127e9498264f4607e4d51a3 to your computer and use it in GitHub Desktop.
function LoadDocument(template) {
var serviceURL = "/ReportingCloud/Template?TemplateName=" + template;
// call the "GET Template" controller method with a template name
$.ajax({
type: "GET",
url: serviceURL,
contentType: 'application/json',
success: successFunc,
error: errorFunc
});
function successFunc(data, status) {
streamType = TXTextControl.StreamType.InternalUnicodeFormat;
// create the proper StreamType based on the extension
if (template.endsWith("docx")) {
streamType = TXTextControl.StreamType.WordprocessingML;
}
else if (template.endsWith("doc")) {
streamType = TXTextControl.StreamType.MSWord;
}
else if (template.endsWith("rtf")) {
streamType = TXTextControl.StreamType.RichTextFormat;
}
// load the document into the widget
textControl1.loadDocument(streamType, data);
// enable the save button and set heading
$("#saveBtn").removeAttr("disabled");
loadedDocument = template;
$("#documentName").text(loadedDocument);
}
function errorFunc(data, success) {
console.log(data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment