如何使用javascript更改ASP .Net MVC Kendo图表的模型?

时间:2022-09-12 09:09:34

I am using the kendo UI MVC wrapper to create a chart. The chart is using a model:

我使用kendo UI MVC包装器来创建图表。该图表使用的是模型:

@(Html.Kendo().Chart<ModelA>()
....

I wish to change the model used by the chart and reload using a new datasource. I am changing the datasource in javascript like this:

我希望更改图表使用的模型,并使用新的数据源重新加载。我正在改变javascript中的数据源,如下所示:

....
var dataSource = new kendo.data.DataSource({
    transport: {
        read: {
            url: "/Controller/_ChartData",
            type: "POST",
            data: dataID
            }
     }
 });

This is firing on a button click to reload the data. The data is reloading correctly. Is this the correct way to change the datasource and how do i change the model that the chart is using (ModelA -> ModelB)

这是在单击按钮时触发以重新加载数据。数据正确重新加载。这是更改数据源的正确方法,以及如何更改图表使用的模型(ModelA - > ModelB)

1 个解决方案

#1


0  

Just modify the dataSource...

只需修改dataSource ......

var dataSource = new kendo.data.DataSource({
    transport: {
        read: {
                url: "/Controller/_ChartData",
                type: "POST",
                data: dataID
            }
        }
    }, 
    schema: {
        model: {
            // ModelB details go here
        }
    });

Have a look at the Kendo documentation.

看看Kendo文档。

#1


0  

Just modify the dataSource...

只需修改dataSource ......

var dataSource = new kendo.data.DataSource({
    transport: {
        read: {
                url: "/Controller/_ChartData",
                type: "POST",
                data: dataID
            }
        }
    }, 
    schema: {
        model: {
            // ModelB details go here
        }
    });

Have a look at the Kendo documentation.

看看Kendo文档。