2
while loading document viewer in a partial view and rendering it to a div is repeatedly loading the previously loaded file
Problem reported by vasanth - 5/26/2017 at 2:18 PM
Resolved
Hi, 
 
Whhile loading document viewer in a partial view and rendering it to a div is repeatedly loading the previously loaded file. 
 
When I load the data into an iframe i don't experience this issue. But in iframe the full screen feature is not working.
 
here is the function i use to load the document viewer in div, 
 
$.ajax({
            type: "GET",
            url: "/Home/GetFile",
            data: { id: Id },
            dataType: "html",
            cache: false,
            beforeSend: function () {
            },
            success: function (result) {
                $('#divFileView').empty();
                $('#divFileView').html(result);
            },
            error: function (error) {
            }
        });
 
Thanks,
Vasanth

6 Replies

Reply to Thread
0
Cem Alacayir Replied
Employee Post
I guess that happens because DocumentViewer renders some JavaScript in the returned html which updates a JS array variable in the page. So as no page refresh occurs, that array keeps being updated and you always get the one from the first index. So it would be better to use an iframe, you can make the full screen work like this:
 
<iframe src=" ViewDocument?f=somefile.doc" width="800"  height="600" style="border: 1px solid #d0d0d0" allowFullScreen webkitallowfullscreen mozallowfullscreen>
 
By default browsers limit iframe "full screen" permission but when you put above properties, it will be allowed.
 
 
0
Cem Alacayir Replied
Employee Post
If you don't want to use iframe, maybe you can do this in your partial view:
 
@Html.RenderControl(Model)

<script type="text/javascript">
	documentViewersToRender  = null
</script>
So after you render the DocumentViewer, you put this JS which clears the global array.
0
vasanth Replied
Thank you so much as the iframe fix works, i am happy with it.
0
Cem Alacayir Replied
Employee Post
Ok good to know. However I am still adding this as a bug, we should be able to fix it if we clear that array internally.
0
Cem Alacayir Replied
Employee Post
For future reference, this should now work in v3.0.5:
 
Fixed: When rendering DocumentViewer in a MVC partial view called by AJAX, even when the HTML was cleared between repeated AJAX requests, DocumentViewer was still using the document and config from the first result. Made sure a global JS array is cleared after each DocumentViewer was rendered.
0
Rakesh Patel Replied
I have stream in mvc controller. I want to render the document in partial view.

Reply to Thread