Dynamically change Chart Data

2 posts, 0 answers
  1. Tong
    Tong avatar
    8 posts
    Member since:
    Feb 2016

    Posted 10 Mar Link to this post

    I want to change chart data based on selection from TreeView or other controls. I have tried to search all solutions on internet, including here...the following seems the right approach but not working for me...

    First, I get selected ID from TreeView, then try to use it as parameter to call an Action by URL..

    Anything wrong here? Thanks

    <script>
        function onSelect(e) {
            var data = $('#MarketDrivers').data('kendoTreeView').dataItem(e.node);
            //$('#driverlist').html(data.id);
            var ds = new kendo.data.dataSource({
                transport: {
                    read: {
                        type: "GET",
                        url: "/Blotter/getUserViewHist",
                        data: { factorID_: data.id },
                        dataType: "json"
                    }
                }
            });
            var chart = $("#PersonalSummary").data("kendoChart");
            chart.setDataSource(ds);
            chart.dataSource.read();
        }

    </script>

    I have an Action from Blotter controller as below

     public ActionResult getUserViewHist(int factorID_)

  2. Tong
    Tong avatar
    8 posts
    Member since:
    Feb 2016

    Posted 11 Mar in reply to Tong Link to this post

    I figured out...

    First, there is a typo: it's kendo.data.DataSource not kendo.data.dataSource

    Second, the type need to be "POST", not "GET". because I call a controller instead of getting from real url?

    Anyway, good for now

     

  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top