I have a view where I have a TreeList that when clicking on the nodes I would like to display PDF files on the same view.
For this every time I click on the nodes it calls a controller sent as a parameter an ID and this returns the file currently works but opens it in another tab. What I want to do is somehow display in another panel to the right of the TreeList the documents in the view.
I leave an image for better understanding and the code below
Currently the PDF opens in another tab
I want to display the document on the right panel of the screen
View
@model ViewModels.Home.MRecords
<script>
> This function when clicking on the nodes call Controller and return PDF document.
function onNodeClick(s, e) {
window.location.href = '@Url.Action("GetAttachments", "Home")' + "?Id=" + e.nodeKey
}
//Here I call to the actually Partial view where I have the TreeList.
@Html.Partial("_TreeListPartial", Model)
Controller that return PDF File
public async Task<ActionResult> GetAttachment(Guid id)
{
var vm = new ViewModels.Home.AttachmentViewModel();
var result = vm.GetServiceAttachment(id));
//Function to get the file information from DB .
byte[] file;
foreach (var attachment in result)
{
file = attachment.File;
byte[] byteArray = file;
return new FileContentResult(byteArray, "application/pdf");
}
return null;
}
I'm only interested in knowing exactly how from the controller I can return a view or something that can be seen in the right panel of my view where I have the TreeList .
Via Active questions tagged javascript - Stack Overflow https://ift.tt/fqZh9d3
Comments
Post a Comment