@(Html.Kendo().Grid<POC_Grid.TblProductDetails>() .Name("Grid") .Columns(column => { //column.Template(m => m.Id); column.Template(m => m.Item).HtmlAttributes(new { @class = "templateCell" }).ClientTemplate(Html.Kendo().AutoComplete() .Name("Item#=uid#") .DataTextField("Item") .Filter("startswith") .MinLength(1) .HtmlAttributes(new { style = "width:250px", @class = "templateCell" }) .DataSource(source => { source.Read(read => { read.Action("getFilteredData", "Grid") .Data("filterDataByText"); }) .ServerFiltering(true); }) .ToClientTemplate().ToHtmlString()); column.Template(m => m.Units).HtmlAttributes(new { @class = "templateCell" }).ClientTemplate(Html.Kendo().NumericTextBox<decimal>() .Name("Units#=uid#") .Format("c") .Min(0) .Max(100) .HtmlAttributes(new { @class = "templateCell" }) .ToClientTemplate().ToHtmlString()); column.Template(m => m.SingleUnitPrice).HtmlAttributes(new { @class = "templateCell" }).ClientTemplate(Html.Kendo().NumericTextBox<decimal>() .Name("SingleUnitPrice#=uid#") .Format("c") .Min(0) .Max(100) .HtmlAttributes(new { @class = "templateCell" }) .ToClientTemplate().ToHtmlString()); column.Template(m => m.Total).HtmlAttributes(new { @class = "templateCell" }).ClientTemplate(Html.Kendo().NumericTextBox<decimal>() .Name("Total#=uid#") .Min(0) .Max(100) //.HtmlAttributes(new { @readonly = "readonly" }) .HtmlAttributes(new { @class = "templateCell",@title="total" }) .ToClientTemplate().ToHtmlString()); }) .Events(ev => ev.DataBound("templateScript") ) .ToolBar(toolbar => { toolbar.Create().Text("+"); toolbar.Save(); }) .Editable(m => m.Mode(GridEditMode.InCell)) .Pageable(p=>p.Refresh(false)) .Sortable() .Scrollable() .Selectable() .HtmlAttributes(new { style = "height:430px;" }) .DataSource(dataSource => dataSource .Ajax() .Batch(true) .Model(model => { model.Id(p => p.Id); }) .PageSize(20) //.Model(m => { m.Id(c => c.Id); }) .Create(create => create.Action("Grid_Create", "Grid")) .Update(update => update.Action("Grid_Update", "Grid")) //.Read(read => read.Action("Grid_Read", "Grid")) )
<script> function templateScript(e) { $(".templateCell").each(function () { eval($(this).children("script").html()); }); } </script>
var grid = $("#Grid").data("kendoGrid"); grid.addRow()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)