This question is locked. New answers and comments are not allowed.
We are using licensed version MVC chart MVC Q2 2011 . I am not able to pass on the parameters to controller method. It does not support .rebind() method. I tried the following, Could not result as expected. I need to have following
1. Should able to pass parameters from view html controls
2. Chart should not be loaded first time
View
@(Html.Telerik().Chart<CollectionDataViewModel>()
.Name("chart")
.Title("Collections By Projects")
.Legend(legend => legend
.Position(ChartLegendPosition.Top)
)
.Series(series =>
{
series.Column(s => s.TotalAmount).Name("Total Amount");
series.Column(s => s.AmountCollected).Name("Collected Amount");
series.Column(s => s.PendingAmount).Name("Pending Amount");
})
.CategoryAxis(axis => axis
.Categories(s => s.Name)
//.Labels(labels => labels.Rotation(-45))
)
.ValueAxis(axis => axis
.Numeric().Labels(labels => labels.Format("${0:#,##0}"))
)
.DataBinding(dataBinding => dataBinding
.Ajax().Select("_CollectionByProject", "Analysis")
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Format("${0:#,##0}")
)
.HtmlAttributes(new { style = "width: 670px; height: 300px;" })
)
Javascript
<script type="text/javascript">
var controllerName = '@this.ViewContext.RouteData.Values["Controller"]';
function getChart() {
return $("#chart").data("tChart");
}
function refresh() {
$.post('@Url.Content("~/")' + '/' + controllerName + '/_CollectionByProject/',
{ fromdate: '09/01/2011', todate: '02/01/2012' });
//getChart().refresh();
}
function rebind() {
// getChart().rebind({ year: $("#year").val() });
getChart().rebind({ year: 2012 });
}
</script>
Controller Method
[HttpPost]
public ActionResult _CollectionByProject(string fromdate, string todate)
{
List<CollectionDataViewModel> ilist = new List<CollectionDataViewModel>();
ilist = Repositories.ReportRepository.GetCollectionData("", fromdate, todate);
return Json(ilist);
}
Model
public class CollectionDataViewModel : ViewModelBase
{
public string RepName { get; set; }
public string Name { get; set; }
public decimal? TotalAmount { get; set; }
public decimal? AmountCollected { get; set; }
public decimal? PendingAmount { get; set; }
}