Hi,
I actually got it working on my own, even though my code ended up quite a bit different then the sample.
However, I do have a question. There are multiple versions of the merge document. I created a ejDialog where the user can select which version of the document that they want to merge. The controller method does the merge with correct word template. It all works, but I would like to close the ejDialog when the merge is complete. I have not been able to figure that out.
Below is some of my code on the client side:
// there is a button in the tool bar that invokes ejDialog
function OnToolbarClick(args) {
if (args.itemName == "Agreement")
{
var gridObj = $("#TelecomGrid").ejGrid("instance");
var rowIndex = gridObj.model.selectedRowIndex;
if (rowIndex > -1) {
var data = gridObj.model.currentViewData[rowIndex];
var temp = $.templates($("#agreementDialog").html());
$(temp.render(data)).ejDialog({ title: "Building Access Agreement" });
} else {
alert("Please select a row for the Building Access Agreement merge document.")
}
}
}
// this is the content of the ejdialog
<script id="agreementDialog" type="text/x-jsrender">
@{
var attributes = new Dictionary<string, object>();
attributes.Add("Id", "BAAForm");
}
@{Html.BeginForm("BuildingAccessAgreement", "Telecom", FormMethod.Post, attributes);
{
<input type="hidden" id="addrId" name="addrId" value="{{:Id}}" />
<div>
<table style="padding-right: 5em;">
<tr><td style="padding-right: 2em;">File:</td><td>{{:SLLFile.FileName}}</td></tr>
<tr>
<td style="padding-right: 2em;">Version:</td>
<td>
<select id="Version" name="Version">
<option value="NOV2017" selected>November 2017</option>
<option value="NOV2017SCHEDB">November 2017 With Sched B</option>
</select>
</td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td colspan="2" style="text-align:center">
<!--<input class="buttonStyle" type="submit" value="Run" />-->
<input class="buttonStyle" type="button" value="Run" onclick="runMergeDoc()" ; />
</td>
</tr>
</table>
</div>
Html.EndForm();
}}
</script>
// this is the javascript function that submits the form. I would to somehow close the ejDialog after the merge.
function runMergeDoc() {
// submits the form, once I figure out how to close the ejDialog I will change this to an Ajax call like in the sample.
// That is the better way to do it in this case
var objForm = document.getElementById("BAAForm");
if (objForm) {
objForm.submit();
// now somehow close dialog
// below are various attempts that did not work
// attempt 1
// var temp = $.templates($("#agreementDialog"));
// temp.ejDialog("close");
// attempt 2
//var temp = $.templates($("#agreementDialog"));
//temp.close();
// attempt 3
//var temp = $.templates($("#agreementDialog").html());
//temp.ejDialog("close");
// attempt 4
//var temp = $.templates($("#agreementDialog").html());
//temp.close();
// attempt 5
//$("#agreementDialog").ejDialog("close");
}
}
Thanks,
Chris