My Model looks Like this:
public class ForecastChartViewModel
{
public int ID { get; set; }
public String PeriodName { get; set; }
public String EstimateDesc { get; set; }
public Decimal EstimateValue { get; set; }
public String ChartColor { get; set; }
public Boolean IsBenchmark { get; set; }
}
I want the periodName to be the values across the X-Axis and each EstimateDesc to be stack on top of each other for that period if IsBenchmark is false, if IsBenchmark is true I'd like to use a line instead of a stack. EstimateValue is the charted Value. I want to be able to set the color for the series to the value of the ChartColor as well.
@(Html.Kendo().Chart<ManpowerForecast.Web.ViewModels.ForecastChartViewModel>()
.Name("chart")
.Legend(legend => legend
.Visible(true)
)
.DataSource(ds => ds
.Read(read => read.Action("ReadManpowerReportForecast", "Manpower"))
.Group(group => group.Add(model => model.EstimateDesc))
.Sort(sort => sort.Add(model => model.PeriodName))
)
.SeriesDefaults(seriesDefaults =>
seriesDefaults.Bar().Stack(true)
)
.Series(series =>
{
series
.Column(model => model.EstimateValue)
.Name("#= group.value #")
.Visible(true);
})
.CategoryAxis(axis => axis
.Categories(model => model.PeriodName)
.MajorGridLines(lines => lines.Visible(false))
.Line(line => line.Visible(false))
)
.ValueAxis(axis => axis.Numeric()
.Max(60)
.MajorGridLines(lines => lines.Visible(false))
.Visible(false)
)
)
In my Controller "ReadManpowerReportForecast" I'm just throwing in some junk data for right now to make sure I can get this chart to function before I go through the complexity of forcing my data into the model in this format. so I could change my model if need be. The code to load the viewmodel looks liket this:
IList<ForecastChartViewModel> vCharts = new List<ForecastChartViewModel>();
ForecastChartViewModel vChart = new ForecastChartViewModel()
{
PeriodName = "Period1",
EstimateDesc = "Project1",
EstimateValue = 20,
IsBenchmark = false,
ChartColor = "#cc00cc"
};
vCharts.Add(vChart);
vChart = new ForecastChartViewModel()
{
PeriodName = "Period1",
EstimateDesc = "Project2",
EstimateValue = 20,
IsBenchmark = false,
ChartColor = "#aa0033"
};
vCharts.Add(vChart);
vChart = new ForecastChartViewModel()
{
PeriodName = "Period1",
EstimateDesc = "Project3",
EstimateValue = 10,
IsBenchmark = true,
ChartColor = "#110011"
};
vCharts.Add(vChart);
vChart = new ForecastChartViewModel()
{
PeriodName = "Period2",
EstimateDesc = "Project1",
EstimateValue = 30,
IsBenchmark = false,
ChartColor = "#cc00cc"
};
vCharts.Add(vChart);
vChart = new ForecastChartViewModel()
{
PeriodName = "Period2",
EstimateDesc = "Project2",
EstimateValue = 12,
IsBenchmark = false,
ChartColor = "#aa0033"
};
vCharts.Add(vChart);
vChart = new ForecastChartViewModel()
{
PeriodName = "Period2",
EstimateDesc = "Project3",
EstimateValue = 5,
IsBenchmark = true,
ChartColor = "#110011"
};
vCharts.Add(vChart);
For example, if I have a change event as below
function sliderChange(e)
{
var msg = "View is changed to " + e.value;
$("#e.ID").html(msg);
}
How can I get slider ID then I can change some control related to this ID?
Thanks
I have two grids, A and B, in one page. After modifying data on A grid, I like to trigger changes in B grid and save it to the server. Is there method I can call through JavaScript to save grid B?
thanks
I've been working on change the class added to a table row of the grid based on the value of a specific cell. For some reason however my code doesn't actually seem to do anything. There are no errors it just doesn't apply a class to the row cell and I don't know why. Can someone do a sanity check for me and make sure I have the code correctly structured please.
The Grid
@(Html.Kendo().Grid<Spoton_Areas_Test.ViewModels.VesselsViewModel>() .Name("Grid") .Columns(columns => { columns.Bound(c => c.fixture_work) .Title("Work"); columns.Bound(c => c.vessel_status) .Title("Status"); }) .Editable(editable => editable.Mode(GridEditMode.InLine)) .Pageable() .Events(e=>e.DataBound("OnDataBound")) .DataSource(dataSource => dataSource .Ajax() .Sort(sort => { sort.Add( company => company.owner_company).Ascending(); }) .PageSize(40) .Model(model => { model.Id(p => p.vessel_idx); }) .Read(read => read.Action("vessels_Read", "Home")) .Update(update => update.Action("vessels_Update", "Home")) ))My Javascript
function onDataBound(e) { var kendoGrid = $("#Grid").data("kendoGrid"); var rows = e.sender.element.find("tbody tr"); for (var i = 0; i < rows.length; i++) { var row = rows[i]; var status = kendoGrid.dataItem(row).vessel_status; if (status = "PPT") { $(row.cells[3]).addClass("customRed"); } } }
I have a grouped Grid in batch mode. My aggregates aren't refreshing as edits are made to the aggregated data until after a .saveChanges is performed. I want the aggregate to update as soon as the focus leaves a cell that is aggregated.
My Columns look like this:
columns.Bound(c => c.Period1)
.HeaderTemplate("<a>" + @title1 + "<br>" + @title2 + "</a>")
//.ClientGroupHeaderTemplate("#= sum #")
.ClientGroupFooterTemplate("#= sum #")
.ClientFooterTemplate("#= sum #")
.Filterable(false)
.Width(100);
My Datasource is configured as such:
.DataSource(dataSource => dataSource
.Ajax()
.AutoSync(false)
.Aggregates(aggregates =>
{
if (Model.Count() > 0) { aggregates.Add(p => p.Period1).Sum(); }
//more aggregate properties here
})
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
.Group(groups => groups.Add(p => p.ProjectType))
.Model(model =>
{
model.Id(prop => prop.ID);
//other model properties here
})
.Create(create => create.Action("CreateManpowerProjectEstimates", "Manpower"))
.Read(read => read.Action("ReadManpowerProjectEstimates", "Manpower"))
.Update(edit => edit.Action("UpdateManpowerProjectEstimates", "Manpower"))
.Destroy(delete => delete.Action("DestroyManpowerProjectEstimates", "Manpower"))
.PageSize(20)
)
I am attempting to post to an action in the controller from a custom button in the Grid component. At first the Grid would render the form outside of the column, this was fixed by {}.Render() which appears to generate the form in the correct location.
My problem is that the items being passed to the form are always null, regardles:
I'll simply my example:
@{Html.Kendo().Grid(Model) .Name("IterationGrid") .Sortable() .Columns(columns => { columns.Tempate(@<text> using (Html.BeginForm("RemindEmployee", "Evaluations", FormMethod.Post)) { Html.Hidden("employeeID", item.Employee.EmployeeID); Html.Hidden("reviewID", item.ReviewId); Html.Hidden("fullname", item.Employee.Fullname); <input type="submit" name="Remind" value="Remind" class="btn btn-primary btn-k-grid" /> }@</text>).Title("Action"); }).Render(); }As I mentioned this appears to work fine, and the Controller has:
[HttpPost]public ActionResult RemindEmployee(int? employeeID, int? reviewID, string fullname) { }Though the parameters are always passed as null. What's the best way to handle this example here?
Note: I've already used some javascript $.post() to do the same thing, but I would like to know the proper way to get the above to work with hidden forms for my own benefit.
Hi,
It’s posible not close grid popup if I have added in modelstate an error on créate or update method of controller.
public ActionResult DirectInCreate([DataSourceRequest]DataSourceRequest request, DirectInViewModel service) { if (ModelState.IsValid) { if (service.OrigenID == 0) { string errorMessage = string.Format("El camp Productor es obligatori."); ModelState.AddModelError("", errorMessage); } Else
function onError(e, gridName) { if (e.errors) { var message = "Errors:\n"; $.each(e.errors, function (key, value) { if ('errors' in value) { $.each(value.errors, function () { message += this + "\n"; }); } }); var grid = $("#" + gridName).data("kendoGrid"); grid.one("dataBinding", function (e) { e.preventDefault(); }) alert(message); grid.cancelChanges(); } }
Thanks in advance.
Xavier de la Rubia.

Hello,
I have a donut chart that uses local data and I'm getting an error on my series of:
Cannot convert lambda expression to type 'System.Collections.IEnumerable' because it is not a delegate typeThe chart is being used in a partial view. Here is my source code.
Partial View
@model IEnumerable<MyProject.ViewModels.UtilisationViewModel> <div class="row"> <div class="col-md-6"> <div class="demo-section k-content wide"> @(Html.Kendo().Chart(Model) .Name("chart") .Title("Utilisation") .Legend(legend => legend .Position(ChartLegendPosition.Bottom)) .Series(series => { series.Donut( model => model.ahts ); }) ) </div> </div></div>The ViewModel
using System;using System.Collections.Generic;using System.ComponentModel.DataAnnotations;using System.Linq;using System.Data.Entity;using System.Web;using Spoton_Areas_Test.Models;namespace MyProject.ViewModels{ public class UtilisationViewModel { public int idx_index { get; set; } public Nullable<System.DateTime> applies_date { get; set; } public Nullable<decimal> ahts { get; set; } public Nullable<decimal> psv { get; set; } public Nullable<int> region_idx { get; set; } public string region_name { get; set; } }}Can anyone point me in the direction of what is going wrong?
Many thanks
I have an existing .NET MVC app where I upgraded it to a Telerik MVC app, and I'm noticing my controls htmlattributes are being overridden it seems.
In my view I have controls like this:
@Html.EditorFor(model => model.CompanyName, new {htmlAttributes = new {@class = "form-control", required = "true"}})
which would previously render like:
<input name="CompanyName" class="form-control text-box single-line" id="CompanyName" required="true" type="text" value="" data-val="true" data-val-length-max="50" data-val-length="50 characters max">
Now with Telerik, they render like this:
<input name="CompanyName" class="k-textbox" id="CompanyName" data-val="true" data-val-length-max="50" data-val-length="50 characters max">
You can see I'm losing my form-control, etc classes, and the required attribute. What is overriding this and how should I handle this?