This is a migrated thread and some comments may be shown as answers.

Dynamically change Chart Data

1 Answer 103 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Tong
Top achievements
Rank 1
Tong asked on 10 Mar 2016, 09:45 PM

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_)

1 Answer, 1 is accepted

Sort by
0
Tong
Top achievements
Rank 1
answered on 11 Mar 2016, 03:17 PM

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

 

Tags
Chart
Asked by
Tong
Top achievements
Rank 1
Answers by
Tong
Top achievements
Rank 1
Share this question
or