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

Passing data to the controller on refresh

3 Answers 151 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Alan Mosley
Top achievements
Rank 1
Alan Mosley asked on 13 Apr 2014, 11:40 AM
I am trying to pass data to the controller using MVC wrappers. But data not being send, controller is executing but data is not passed. am I doing things correctly?
Thanks

var chart = $("#SalesChart").data("kendoChart");
chart.refresh({
    data: { "FromDate": $("#FromDate").data("kendoDatePicker").value(), "ToDate": $("#ToDate").data("kendoDatePicker").value() }
});

‚Äč
@code
           Dim SalesChart As Kendo.Mvc.UI.Chart(Of BO.Models.Statistics.SalesTimeSpan) = _
               Html.Kendo.Chart(Of BO.Models.Statistics.SalesTimeSpan).
               Name("SalesChart").Title("Units sold").Series(Sub(series)
                                                                     series.Line(Function(model) model.Value, categoryExpression:=Function(model) model.Period).
                                                                     Aggregate(ChartSeriesAggregate.Avg)
                                                             End Sub).
           CategoryAxis(Function(axis) axis.Date().BaseUnit(ChartAxisBaseUnit.Weeks)).
           DataSource(Function(ds) ds.Read(Function(read) read.Action("getsalesbydate", "statistics", New With {.area = String.Empty})))
 
           SalesChart.Render()
 
 
       End Code

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 16 Apr 2014, 07:33 AM
Hi,

The refresh method does not accept additional data as parameter. Your should use the chart dataSource read method instead to pass the values e.g.
var chart = $("#SalesChart").data("kendoChart");
chart.dataSource.read({
   "FromDate": $("#FromDate").data("kendoDatePicker").value(),
   "ToDate": $("#ToDate").data("kendoDatePicker").value()
});


Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Alan Mosley
Top achievements
Rank 1
answered on 16 Apr 2014, 12:08 PM
Thanks that worked, I did try that, but I think I left the data: in,
but still I have a problem, the dates from the datepicker are not binging to date objects on the controller. action.
Thanks 
0
Daniel
Telerik team
answered on 17 Apr 2014, 01:41 PM
Hi again,

Could you share the code for the action method? Also, verify that you are using the same culture on the server and on the client. The client-side culture will be used by default to serialize the dates and numbers and the model binder will not parse the values if the culture is not the same.

Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Chart
Asked by
Alan Mosley
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Alan Mosley
Top achievements
Rank 1
Share this question
or