@(Html.Kendo().Grid<MyProject.Business.Models.ParentDTO>().Name("ParentGrid").Columns(cols => cols.Command(o => o.Edit() ).Title(" ")).Editable(editor => editor.Mode(GridEditMode.PopUp)).Events(events=>events.Edit("onEditOfParentGrid")).DataSource(datasource => datasource .Ajax() .Model(model => model.Id(o => o.id)) .Read(read => read.Action("GetAll", "ParentAjax")) .Update(update => update.Action("Update", "ParentAjax")) .Create(create => create.Action("Create", "ParentAjax")) .Destroy(destroy => destroy.Action("Destroy", "ParentAjax")) ))<script type="text/javascript"> function onEditOfParentGrid(e) { $('#ChildGrid').data().kendoGrid.dataSource.read({ id: e.model.id }) }</script>@model MyProject.Business.Models.ParentDTO@(Html.Kendo().Grid<MyProject.Business.Models.ChildDTO>().Name("ChildGrid").AutoBind(false).Editable(edit=>edit.Mode(GridEditMode.InCell)).DataSource(datasource => datasource .Ajax() .Model(model =>model.Id(o => o.id)) .Read(read => read.Action("GetByParentId", "ChildAjax")) .Update(update => update.Action("Update", "ChildAjax")) .Create(create => create.Action("Create", "ChildAjax")) .Destroy(destroy => destroy.Action("Destroy", "ChildAjax"))))In my grid I placed a custom command "Copy" which copies a value of a column to two other values in other columns in the Click-handler CopyClick. Now I would like to enter the edit mode for the row. How can I do that? I tried grid.editRow(row) but it did not worked. Probably I passed the wrong parameter to it. What must row be as a parameter to editRow()?
@(Html.Kendo().Grid<MyViewModel>() .Name("MyGrid") .Columns(columns => { columns.Command(command => { command.Edit(); command.Destroy(); command.Custom("Copy").Click("CopyClick"); }); …… function CopyClick(e) { e.preventDefault(); var grid = $("#UnterhaltGrid").data("kendoGrid"); var dataItem = this.dataItem($(e.currentTarget).closest("tr")); dataItem.Val1 = dataItem.Val0; dataItem.Val2 = dataItem.Val0; grid.refresh(); }
I want to bind to a controller called articles but am getting an exception as follows
0x800a138f - JavaScript runtime error: Unable to get property 'DataSource' of undefined or null reference
<!DOCTYPE html >
<HTML>
<head>
<title>content</title>
<link href="~/Content/kendo/2012.2.710/kendo.common.min.css" rel="stylesheet" />
<link href="~/Content/kendo/2012.2.710/kendo.default.min.css" rel="stylesheet" />
</head>
<body>
<div id="articlesgrid"> </div>
<script src="~/Scripts/jquery-1.7.2.js"></script>
<script src="~/Scripts/kendo/2012.2.710/kendo.web.min.js"></script>
<script>
$(function()
{
$("#articlesgrid").kendoGrid(
{
dataSource: new kendo.Data.DataSource({
transport: {
read : "Api/Articles"
}}
)
})
}
);
</script>
</body>
</HTML>
#''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public class ArticlesController : Controller
{
public List<Article> Get()
{
List<Article> lst = new List<Article>();
lst.Add(new Article() { ID = 1, Name = "AAA", Price1 = 1.22m });
lst.Add(new Article() { ID = 1, Name = "BBB", Price1 = 1.32m });
lst.Add(new Article() { ID = 1, Name = "CCC", Price1 = 1.42m });
return lst;
}
}
}
<div class="k-widget k-chart" id="chart"></div><script> jQuery(function(){jQuery("#chart").kendoChart({series:[{name:"Sale Value",type:"area",field:"SaleValue"}],categoryAxis:{categories:["2007","2008","2009","2010","2011"]},dataSource:{data:[{"Year":2007,"SaleValue":250000.0000},{"Year":2008,"SaleValue":500000.0000},{"Year":2009,"SaleValue":250000.0000},{"Year":2010,"SaleValue":500000.0000},{"Year":2011,"SaleValue":250000.0000}]}});}); </script>
@(Html.Kendo().Chart(Model.AnnualSalesList)
.Name("chart")
.Series(series =>
{
series.Area(s => s.SaleValue);
})
.CategoryAxis(axis => axis
.Categories(s => s.Year))
)
@*
@(Html.Telerik().Chart(Model.AnnualSalesList)
.Name("chart")
.Legend(false)
.Series(series =>
{
series.Area(s => s.SaleValue).Name("Sales by Year");
})
.CategoryAxis(axis => axis
.Categories(s => s.Year))
.ValueAxis(axis => axis
.Numeric().Labels(labels => labels.Format("${0:#,##0}")))
.Theme("Metro")
.HtmlAttributes(new { style = "width: 450px; height: 200px; margin: auto;" })
)
*@
@(Html.Kendo().Grid<MyProject.Business.Models.EmployeDTO>().Name("EmployeGrid").ToolBar(toolbar => toolbar.Create()).Columns(cols =>{ cols.Bound(o => o.someData).Title("Some Data"); cols.Bound(o => o.moreData).Title("More Data"); cols.Command(o => { o.Edit(); o.Destroy(); }).Title(" ");}).Editable(editor => editor .Mode(GridEditMode.PopUp) .Window(window => window.Draggable().Resizable().HtmlAttributes(new { @style = "width:700px;" }))).Sortable().Filterable().Groupable().DataSource(datasource => datasource .Ajax() .Model(model => model.Id(o => o.id)) .Read(read => read.Action("GetAll", "EmployesAjax")) .Update(update => update.Action("Update", "EmployesAjax")) .Create(create => create.Action("Create", "EmployesAjax")) .Destroy(destroy => destroy.Action("Destroy", "EmployesAjax")) ))@Html.Kendo().Grid<MyProject.Business.Models.SalairyDTO>().Name("SalaryGrid").Columns(cols =>{ cols.Bound(o => o.someInfo).Title("Some Info");}).DataSource(datasource => datasource .Ajax() .Model(model => { model.Id(o => o.id); model.Field(o => o.employe_id).DefaultValue(Model.id); }) // NEED THE ID HERE .Read(read => read.Action("GetByEmployeId", "SalairyAjax", new { id = "" })) .Update(update => update.Action("Update", "SalairyAjax")) .Create(create => create.Action("Create", "SalairyAjax")) .Destroy(destroy => destroy.Action("Destroy", "SalairyAjax"))));