or
@{ var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); string fundsJson = serializer.Serialize(Model.Funds);}<script id="dropdown-template" type="x-tmpl-mustache"> <input type="hidden" name="[{{index}}].IndexInXml" value="{{indexInXml}}" /> <input id="_{{index}}__FundId" name="[{{index}}].FundId" style="width: 300px" type="text" /> {{attachComboBox}}</script><script> var currentDropDownIndex = 0; var fundsJson =@Html.Raw(fundsJson)@(";") function attachDropDown(dropDownIndex) { jQuery("#_" + dropDownIndex + "__FundId").kendoDropDownList( { "dataSource": fundsJson, "dataTextField": "FundName", "height": 250, "headerTemplate": "<div class=\"dropdown-header\"><span class=\"k-widget k-header\">Fund</span><span class=\"k-widget k-header\">Reg</span></div>", "template": "<span class=\"k-state-default\">#: data.FundName #</span><span class=\"k-state-default\">#: data.Reg #</span>", "valueTemplate": "<span>#:data.FundName#</span>", "dataValueField": "FundId", }); } function getDropDown(indexInXml) { var view = { index: currentDropDownIndex, indexInXml: indexInXml, attachComboBox: function () { (function (currentDropDownIndex) { jQuery(function () { console.log(currentDropDownIndex); attachDropDown(currentDropDownIndex); }); })(currentDropDownIndex); } }; var template = $('#dropdown-template').html(); Mustache.parse(template); var rendered = Mustache.render(template, view); currentDropDownIndex++; return rendered; } function init() { currentDropDownIndex = 0; }</script>@(Html.Kendo().Grid<Administration.ViewModels.UnmappedFundInfoViewModel>(Model.ImportedFundData) .Name("funds-mapping") .Sortable() .Columns(columns => { columns.Bound(c => c.ImportedFundName) .Title("Imported fund name"); columns.Bound(c => c.FundId).Title("Fund ID").Width(100); columns.Template(@<text> </text>).Title("Linked fund").ClientTemplate("#= getDropDown(data.IndexInXml)#"); }) .Scrollable(x => x.Enabled(true).Height("250px")) .DataSource(dataSource => dataSource.Ajax().ServerOperation(false) ) .Resizable(resize => resize.Columns(true)) )<script> $(document).ready(function () { var grid = $("#funds-mapping").data("kendoGrid"); grid.bind("dataBinding", function () { init(); }); });</script>@(Html.Kendo().Grid<dynamic>()
....DataSource(d =>{ d.Ajax() .Model(m => { m.Id("Id"); m.Field("Name", typeof(string)).Editable(false);[RuntimeBinderException: 'object' does not contain a definition for 'Name'] CallSite.Target(Closure , CallSite , Object ) +152 System.Dynamic.UpdateDelegates.UpdateAndExecute1(CallSite site, T0 arg0) +662 lambda_method(Closure , Object ) +133 Kendo.Mvc.UI.Html.GridDataCellBuilder`2.AppendCellContent(IHtmlNode td, Object dataItem) +131 Kendo.Mvc.UI.Html.GridDataCellBuilderBase.CreateCell(Object dataItem) +230@(Html.Kendo().Grid(Model.Result.Data) .Name("gridSearchResults") .Columns(columns => { foreach (System.Data.DataColumn column in Model.Result.Data.Columns) { if (column.ColumnName != "Id") { if (column.ColumnName == "Name") { columns.Bound("Name").Template(@<text><a href='" + Url.Action("Details", Model.Result.DataSource) + "/#= Id #'" + ">#= Name #</a></text>); } else { columns.Bound(column.ColumnName); } } } }) .DataSource(d => d .Server() .Model(m => { m.Id("Id"); foreach (System.Data.DataColumn column in Model.Result.Data.Columns) { m.Field(column.ColumnName, column.DataType); } }) ))@(Html.Kendo().Grid<Reports.ReportRow>() .Name("grdReport") .DataSource(dataSource => dataSource .Ajax() .Read(read => read .Action("AJAX", "Report") .Data("GetReportParms") ) ) .ToolBar(tools => { tools.Excel(); tools.Template(@<text> <div class="toolbar"> <label class="category-label" for="category">Version:</label> @(Html.Kendo().DropDownList() .Name("ddlField") .DataTextField("Text") .DataValueField("Value") .AutoBind(true) .Events(e => e.Change("fieldChange")) .DataSource(ds => { ds.Read("FieldType", "Common"); }) ) </div> </text>); })function OpenAddRowMenu(event) { var contextMenu = $("#AddRowMenu"); if ((!event.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), event.relatedTarget))) { contextMenu.show(event);
} else { alert("Event error"); }}
The button
<button class="btn btn-primary" onclick="OpenAddRowMenu(event); return false;">Add Row</button>
$("#exportASPBarChart").click(function () { var chart = $("#ASPBarChart").data("kendoChart"); var image = chart.imageDataURL(); var a = $("<a>").attr("href", image).attr("download", "ASPBarChart.png").appendTo("body"); a[0].click();});