Hi, here is the problem. I have mvc chart set in razor view. Here is the definition:
<div class="demo-section k-content wide">
@(Html.Kendo().Chart<List<Novolyze.VOD.WebUI.Models.ChartSource>>()
.AutoBind(false)
.DataSource(dataSource => dataSource
.Read(read => read
.Action("DailyStatisticJson", "Production")
//.Data("getFilterParams")
)
.Group(group => group
.Add<string>("SeriesName"))
)
.Name("dailyStatisticChart")
.Title("Daily Statistic")
.Zoomable(zoomable => zoomable
.Mousewheel(mousewheel => mousewheel
.Lock(ChartAxisLock.Y))
.Selection(selection => selection
.Lock(ChartAxisLock.Y)))
.Pannable(pannable => pannable
.Lock(ChartAxisLock.Y))
.Legend(legend => legend
.Visible(false)
)
.SeriesDefaults(seriesDefaults => seriesDefaults
.Column()
.Stack(true)
)
.Series(series => series
.Column(model => model).Field("Value").CategoryField("Category").ColorField("ColorName")
)
.CategoryAxis(axis => axis
.Date()
.BaseUnit(ChartAxisBaseUnit.Days)
.Labels(labels => labels
.Rotation("auto"))
)
)
I also have contlroler method:
public ActionResult DailyStatisticJson([DataSourceRequest] DataSourceRequest request)
{
//Some logic and return datasource JSON, that works well
}
I want to refresh the chart with new data based on some external filtering. I have the following Javascript code that should do the trick, but it doesn't
function executeFilter(filters) {
var chart = $("#dailyStatisticChart").data("kendoChart");
if (chart) {
chart.dataSource.filter(filters);
//chart.dataSource.read();
}
}
The point is: if I call just filter() and not the read(), chart data disappear, controller is not called. If I uncomment read(), then controller is called, but filter property is empty in the controller parameter. I can find the workaround to pass additional data with uncommenting Data to datasource definition but then I will use another param in controller, not DatasourceRequest, which will be uglier. Is there a solution with filter?