ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  how to use web real time chart in partial view?? MVC
Posted by Sinthu Manikandan on May-09-2017 10:28
Hi Support Team,

                  I want to call real time scrolling chart from partial view. in Partial View

JsChartViewer.addEventListener(window, 'load', function ()
             {
});

this function not Calling, without this load function i ran its shows addeventlistener issue..
Please help me. how to do??

  Re: how to use web real time chart in partial view?? MVC
Posted by Peter Kwan on May-10-2017 04:11
Hi Sinthu,

I have tried myself, and it works normally in my case.

The controller is:

public class Test : Controller
{
    public ActionResult Index()
    {
        return View("~/Views/Shared/MyMainView.cshtml");
    }
}

My main view is:

@{ Layout = null; }
<!DOCTYPE html>
<html>
<head>
   @Scripts.Render("~/Scripts/cdjcv.js")
</head>
<body>
    <div>I am a main view. </div>
    @Html.Partial("~/Views/Shared/Test.cshtml")
</body>
</html>

My partial view "~/Views/Shared/Test.cshtml" is:

@{ Layout = null; }

<script>
    JsChartViewer.addEventListener(window, 'load', function () {
       alert(134);
    });
</script>
<div>
   I am a partial view.
</div>

When I tried the above, the browser shows pop up a message box displaying "134". It proves the addEventListener is running normally.

There are many reasons why some code does not work. For example, may be the code forgets to include "cdjcv.js" or including it too late. (The "cdjcv.js" must be included before using the JsChartViewer.) Or the "partial view" is included only have the main HTML page is completed loaded. (As the JsChartViewer code listens to the window.load event, obviously it needs to be loaded before the window.load event has occurred.) Other issues including incorrect HTML code, etc..

If you think addEventListener is not running, is it possible to provide a simple example that I can try and that can illustrate the problem?

I assume you are familiar with HTML and already know that each id attribute must be unique. If your partial view is designed to be used multiple times in the same web, it needs to be designed to use a different ids for each of its instances.

Regards
Peter Kwan