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 type
The 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?
Hi,
I have a grid with subgrids on page. And I had to make custom delete button which shows delete dialog window (default kendo behaviour - show alert, not acceptable in my app).
But when someone press delete-button in subgrid, it invokes click on delete button in main grid (via injected.js, I understood that in debug proccess in chrome). I dont need that behaviour. How to prevent click on delete button in main grid?
Provide part of code here, and all code of this page in Attachment
Code :
//Main grid
@(Html.Kendo().Grid<TerminalViewModel>()
.Name(
"TerminalsGrid"
)
.Columns(c =>
{
c.Bound(x => x.Brand.Name)
c.Bound(x => x.TerminalModel.Name)
c.Bound(x => x.SerialNumber)
c.Bound(x => x.CommissioningDate)
c.Bound(x => x.CurrentAZS)
c.Command(command => command.Edit()
.HtmlAttributes(
new
{ style =
"text-align: center;"
})
.Width(131);
c.Command(command => command.Custom(
"Delete"
)
.Text(
"<span class='k-icon k-delete'></span>Удалить"
)
.Click(
"prepareToDelete"
))
.HtmlAttributes(
new
{ style =
"text-align: center;"
});
})
.Events(x => x
.Save(
"onSaveDisableUpdateButton"
)
.DataBound(
"onDataBoundHideControlButtons"
))
.DataSource(ds => ds
.Ajax()
.Events(e => e
.Error(
"onErrorInCatalogs"
))
.Model(m =>
{
m.Id(x => x.Id);
m.Field(x => x.Brand).DefaultValue(
new
ListItemIntViewModel { Name =
""
});
m.Field(x => x.TerminalModel).DefaultValue(
new
ListItemIntViewModel { Name =
""
});
m.Field(x => x.Organization).DefaultValue(
new
ListItemViewModel { Name =
""
});
m.Field(x => x.Contractor).DefaultValue(
new
ListItemViewModel { Name =
""
});
})
.Read(r => r.Action(
"JsonRead"
,
"Terminals"
))
.Create(c => c.Action(
"JsonCreate"
,
"Terminals"
))
.Update(u => u.Action(
"JsonUpdate"
,
"Terminals"
))
)
.Editable(editable => editable.Mode(GridEditMode.PopUp)
.TemplateName(
"EditTerminal"
)
.Window(x => x.Width(550).Title(
"Данные терминала"
)))
.ToolBar(t => t.Create())
.Sortable(s => s.AllowUnsort(
true
))
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.ClientDetailTemplateId(
"template"
)
.Scrollable(scroll => scroll.Height(
"auto"
))
.Pageable()
.Events(events => events
.DetailExpand(
"detailExpand"
)
.DetailCollapse(
"detailCollapse"
))
)
// Helper for Delete Window
@Html.DeleteModal()
//Subgrid
@helper StateChanges()
{
@(Html.Kendo().Grid<TerminalStatesChangeHistoryViewModel>()
.Name(
"grid_state_changes_#=Id#"
)
.Columns(columns =>
{
columns.Bound(col => col.TerminalState.Name)
.EditorTemplateName(
"EditTerminalState"
);
columns.Bound(col => col.StartTime)
.EditorTemplateName(
"DateTimeEditor"
);
columns.Bound(col => col.EndTime)
.EditorTemplateName(
"DateTimeNullableEditor"
);
columns.Command(c => c.Edit())
.HtmlAttributes(
new
{ style =
"text-align: center;"
});
columns.Command(command => command.Custom(
"Delete"
)
.Text(
"<span class='k-icon k-delete'></span>Удалить"
)
.Click(
"prepareToDeleteInSubgrid"
))
.HtmlAttributes(
new
{ style =
"text-align: center;"
});
})
.Sortable()
.Events(x => x
.Save(
"onSaveDisableUpdateButton"
)
.DataBound(
"onDataBoundHideControlButtons"
))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.ToolBar(toolbar => { toolbar.Create(); })
.DataSource(data => data
.Ajax()
.Sort(sort => sort.Add(
"StartTime"
).Descending())
.Events(events =>
{
events.Error(
"onErrorInSubgrid.bind({ WidgetID: 'grid_state_changes_#=Id#'})"
);
events.Sync(
"onSubgridSync.bind({ WidgetID: 'grid_state_changes_#=Id#'})"
);
})
.Model(model =>
{
model.Id(m => m.Id);
model.Field(x => x.TerminalState).DefaultValue(
new
ListItemIntViewModel());
model.Field(x => x.StartTime).DefaultValue(DateTime.Now);
})
.Create(update => update.Action(
"StateChangesCreate"
,
"Terminals"
,
new
{ terminalId =
"#= Id #"
}))
.Read(read => read.Action(
"StateChangesRead"
,
"Terminals"
,
new
{ terminalId =
"#= Id #"
}))
.Update(update => update.Action(
"StateChangesUpdate"
,
"Terminals"
))
)
.Pageable(pager => pager.Refresh(
true
))
.ToClientTemplate()
)
}
<script>
function
prepareToDeleteInSubgrid(e) {
e.preventDefault();
var
gridId =
this
.element[0].id;
if
(gridId.indexOf(
"state_changes"
) > 0) {
deleteUrl = deleteStateChangeUrl;
}
else
if
(gridId.indexOf(
"fuel_station_changes"
) > 0) {
deleteUrl = deleteFuelStationChangeUrl;
}
else
return
;
showDelete(e,
this
);
}
function
prepareToDelete(e) {
var
gridId =
this
.element[0].id;
deleteUrl = deleteTerminalUrl;
showDelete(e,
this
);
}
function
showDelete(e, gridWidget) {
if
(gridWidget == undefined) {
gridWidget =
this
;
}
var
target = $(
'#deleteModal'
);
var
id = gridWidget.dataItem($(e.currentTarget).closest(
"tr"
)).id;
gridname =
'#'
+ gridWidget.element[0].id;
target.find(
'#entryId'
).val(id);
$(
'#PopupDeleteExceptionSection'
).css(
"display"
,
"none"
);
target.modal();
}
</script>
Hello,
i am using Kendo TreeView in tablet and phones. It is very difficult to expand and collapse nodes by touching as the Images are very small for touch. So i did create bigger Images and did overqrite like this
.k-treeview .k-minus {
background-position: 0 0;
background: url("@Url.Content("~/Images/Actions-arrow-down-icon.png")") center center;
width: 25px;
height:25px;
cursor: pointer;
position:relative;
left: -10px;
top: 5px;
}
.k-treeview .k-plus {
background-position: 0 0;
background: url("@Url.Content("~/Images/Actions-arrow-right-icon.png")") center center;
width: 25px;
height: 25px;
cursor: pointer;
position:relative;
left: -10px;
top: 5px;
}
But even with bigger Images the touch is not improved. When i tap on bigger arrow it does not take the touch throughout the Image. How can i improve the touch area for mobile devices? Same is thr Problem for Kendo menu on devices. When clicked it does not seem to take touch always.
Thanks
Anamika
Given an empty radar line chart, is it possible to have the plotlines still colored as if there were data? Here's a dojo example: http://dojo.telerik.com/@buffcessna/ELoha
If you un-comment the data line, the graph looks fine. But by commenting out the data line, the entire graph is green per the plotbands.
Is there a way for the graph to be colored like the plotbands state even if there's no data present?
Question around grouping. I've noticed that when the grid's read happens it calls the assigned web method as you would expect. What I have noticed that the code below produced two different results. One for grouped data and another type for all other grid alterations (filters and sorts).
Sample code:
Dim temp As IQueryable = grid.ToDataSourceResult(request).Data.AsQueryable
No grid alterations or filtering or sorting the data type of the above object is:
System.Linq.EnumerableQuery(Of myDataType)
Apply one or more groups and the data type becomes:
System.Linq.EnumerableQuery(Of Kendo.Mvc.Infrastructure.AggregateFunctionsGroup)
Why does this happen? Have we implemented something incorrectly?
Hello,
when will be the support available for RC version?
Best Regards
Any time I try to do an update with InCell editing I get a javascript error as soon as I click out of the cell button.
function
anonymous(d) {
return
d.x.Col2
// 0x800a138f - JavaScript runtime error: Unable to get property 'Col2' of undefined or null reference
}
The d value seems to have my object (CP_FailureStrategyMatrixRow) in it just fine, i.e. it has a attribute called "Col2" that has a valid value in it. I feel everything would work just fine if it was doing "d.Col2", instead of looking in some inner value called x. But I have no idea where this "x" is coming from.
It never even gets to the server-side code:
I have tried it with both versions of the CRUD operations, as the examples on telerik seem to use both, but it doesn't seem to matter which update statement I use.
@model XDashboard.Models.GridModel
@using Kendo;
@using Kendo.Mvc;
@using Kendo.Mvc.UI;
@(Html.Kendo().Grid<
XDashboard.Models.CP_FailureStrategyMatrixRow
>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.Col1);
columns.Bound(p => p.Col2).Width(140);
columns.Bound(p => p.Col3).Width(140);
//columns.Bound(p => p.ProbabilityOfFailureValue).Width(100);
columns.Command(commands =>
{
commands.Destroy(); // The "destroy" command removes data items
}).Title("Commands").Width(200);
})
// .Events(e => e.DataBound("OnChange")) //this will attach to the events for the grid
.ToolBar(toolbar =>
{
toolbar.Create(); // The "create" command adds new data items
toolbar.Save(); // The "save" command saves the changed data items
})
.Editable(editable => editable.Mode(GridEditMode.InCell)) // Use in-cell editing mode
.DataSource(dataSource =>
dataSource.Ajax()
.Batch(false) // Enable batch updates
.Events(events => events.Error("error_handler")) //this will grab the events for the datasource, notice hwo we are inside the method for datasource
.Events(events => events.Change("OnChange"))
//.Events(events => events.Sync("OnChange"))
.Model(model =>
{
model.Id(product => product.ProbabilityOfFailureValue); // Specify the property which is the unique identifier of the model
model.Field(product => product.ProbabilityOfFailureValue).Editable(false); // Make the ProductID property not editable
})
.Create(create => create.Action("Create2", "ManagementStrats")) // Action method invoked when the user saves a new data item
.Read(read => read.Action("Read", "ManagementStrats")) // Action method invoked when the grid needs data
.Update(update => update.Action("Update2", "ManagementStrats")) // Action method invoked when the user saves an updated data item
.Events(events => events.Error("error_handler"))
.Destroy(destroy => destroy.Action("Destroy2", "ManagementStrats")) // Action method invoked when the user removes a data item
)
.Pageable()
)
<
script
type
=
"text/javascript"
>
function error_handler(e) {
if (e.errors) {
var message = "Errors:\n";
$.each(e.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n";
});
}
});
alert(message);
}
}
}
public
class
ManagementStratsController : Controller
{
public
ActionResult Index()
{
return
View();
}
public
ActionResult Read([DataSourceRequest] DataSourceRequest request)
{
XEntities db =
new
XEntities();
ManagementStratsService productService =
new
ManagementStratsService(db);
return
Json(productService.Read().ToDataSourceResult(request));
}
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix =
"models"
)]IEnumerable<CP_FailureStrategyMatrixRow> products)
{
XEntities db =
new
XEntities();
ManagementStratsService productService =
new
ManagementStratsService(db);
var results =
new
List<CP_FailureStrategyMatrixRow>();
if
(products !=
null
&& ModelState.IsValid)
{
foreach
(var product
in
products)
{
productService.Create(product);
results.Add(product);
}
}
return
Json(results.ToDataSourceResult(request, ModelState));
}
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult Create2([DataSourceRequest] DataSourceRequest request, CP_FailureStrategyMatrixRow product)
{
XEntities db =
new
XEntities();
ManagementStratsService productService =
new
ManagementStratsService(db);
var results =
new
List<CP_FailureStrategyMatrixRow>();
if
(product !=
null
&& ModelState.IsValid)
{
productService.Create(product);
results.Add(product);
}
return
Json(results.ToDataSourceResult(request, ModelState));
}
//[AcceptVerbs(HttpVerbs.Post)]
//public ActionResult Update([DataSourceRequest] DataSourceRequest request, CP_FailureStrategyMatrixRow product)
//{
// if (product != null && ModelState.IsValid)
// {
// XEntities db = new XEntities();
// ManagementStratsService productService = new ManagementStratsService(db);
// }
// return Json(new[] { product }.ToDataSourceResult(request, ModelState));
//}
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix =
"models"
)]IEnumerable<CP_FailureStrategyMatrixRow> products)
{
XEntities db =
new
XEntities();
ManagementStratsService productService =
new
ManagementStratsService(db);
if
(products !=
null
&& ModelState.IsValid)
{
foreach
(var product
in
products)
{
productService.Update(product);
}
}
return
Json(products.ToDataSourceResult(request, ModelState));
}
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult Update2([DataSourceRequest] DataSourceRequest request, CP_FailureStrategyMatrixRow product)
{
XEntities db =
new
XEntities();
ManagementStratsService productService =
new
ManagementStratsService(db);
if
(product !=
null
&& ModelState.IsValid)
{
productService.Update(product);
}
return
Json(
new
[] { product }.ToDataSourceResult(request, ModelState));
}
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult Destroy([DataSourceRequest] DataSourceRequest request, [Bind(Prefix =
"models"
)]IEnumerable<CP_FailureStrategyMatrixRow> products)
{
XEntities db =
new
XEntities();
ManagementStratsService productService =
new
ManagementStratsService(db);
if
(products !=
null
&& ModelState.IsValid)
{
foreach
(var product
in
products)
{
productService.Destroy(product);
}
}
return
Json(products.ToDataSourceResult(request, ModelState));
}
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult Destroy2([DataSourceRequest] DataSourceRequest request, CP_FailureStrategyMatrixRow product)
{
XEntities db =
new
XEntities();
ManagementStratsService productService =
new
ManagementStratsService(db);
if
(product !=
null
&& ModelState.IsValid)
{
productService.Destroy(product);
}
return
Json(
new
[] { product }.ToDataSourceResult(request, ModelState));
}
//public ActionResult Unique(string field)
//{
// var result = GetCP_FailureStrategyMatrixRows().Distinct(new CP_FailureStrategyMatrixRowComparer(field));
// return Json(result, JsonRequestBehavior.AllowGet);
//}
}
public
class
CP_FailureStrategyMatrixRow
{
public
int
ProbabilityOfFailureValue {
get
;
set
; }
public
string
Col1 {
get
;
set
; }
public
string
Col2 {
get
;
set
; }
public
string
Col3 {
get
;
set
; }
public
string
Col4 {
get
;
set
; }
public
string
Col5 {
get
;
set
; }
public
string
Col6 {
get
;
set
; }
public
string
Col7 {
get
;
set
; }
public
string
Col8 {
get
;
set
; }
public
string
Col9 {
get
;
set
; }
public
string
Col10 {
get
;
set
; }
internal
CP_FailureStrategyMatrix_Test transform()
{
CP_FailureStrategyMatrix_Test row =
new
CP_FailureStrategyMatrix_Test();
row.Col1 = Col1.Length == 1 ? (
int
?)(Char.GetNumericValue(Col1[0]) - 64) :
null
;
row.Col2 = Col2.Length == 1 ? (
int
?)(Char.GetNumericValue(Col2[0]) - 64) :
null
;
row.Col3 = Col3.Length == 1 ? (
int
?)(Char.GetNumericValue(Col3[0]) - 64) :
null
;
row.Col4 = Col4.Length == 1 ? (
int
?)(Char.GetNumericValue(Col4[0]) - 64) :
null
;
row.Col5 = Col5.Length == 1 ? (
int
?)(Char.GetNumericValue(Col5[0]) - 64) :
null
;
row.Col6 = Col6.Length == 1 ? (
int
?)(Char.GetNumericValue(Col6[0]) - 64) :
null
;
row.Col7 = Col7.Length == 1 ? (
int
?)(Char.GetNumericValue(Col7[0]) - 64) :
null
;
row.Col8 = Col8.Length == 1 ? (
int
?)(Char.GetNumericValue(Col8[0]) - 64) :
null
;
row.Col9 = Col9.Length == 1 ? (
int
?)(Char.GetNumericValue(Col9[0]) - 64) :
null
;
row.Col10 = Col10.Length == 1 ? (
int
?)(Char.GetNumericValue(Col10[0]) - 64) :
null
;
row.ProbabilityOfFailureValue = ProbabilityOfFailureValue;
return
row;
}
//public partial class CP_FailureStrategyMatrix_Test
//{
// public int ProbabilityOfFailureValue { get; set; }
// public Nullable<int> Col1 { get; set; }
// public Nullable<int> Col2 { get; set; }
// public Nullable<int> Col3 { get; set; }
// public Nullable<int> Col4 { get; set; }
// public Nullable<int> Col5 { get; set; }
// public Nullable<int> Col6 { get; set; }
// public Nullable<int> Col7 { get; set; }
// public Nullable<int> Col8 { get; set; }
// public Nullable<int> Col9 { get; set; }
// public Nullable<int> Col10 { get; set; }
//}
}
Every time the chart is drawn the background is set to gray. No matter if the theme is specified or not or if the chart area background is set to "", "transparent" or any color, or not at all.
You can see a blank chart with the correct background color prior to the read occurring and the chart being redrawn with the appropriate data. Each path element in the SVG has a stroke color set to "#dfdfdf"
Here is the code:
@(Html.Kendo( ).Chart<ViewModels.HistoryChartModel>( )
.Name( "chart" )
.ChartArea(c=>c.Width(800).Height(600))
.DataSource( dataSource => dataSource
.Read( read => read.Action( "Series", "Home" ) )
.Group( group => group.Add( model => model.BasinName ) )
.Sort( sort => sort.Add( model => model.ReadingDateTime ).Descending( ))
)
.Series( series => {series.Line( model => model.LevelReading ).Name( "#= group.value # " ).Markers(false);} )
.Legend( legend => legend.Position( ChartLegendPosition.Bottom ))
.ValueAxis( a => a.Numeric( ).Min( 3 ).Max(10).MinorTicks(mt=>mt.Visible(false)).MajorUnit(.5) )
)