or
public static class HtmlHelperExtensions
{
public static GridBuilder<
T
> SavitarCRUDGrid<
T
>(this HtmlHelper helper, string name)
where T : class, IEntity
{
string entityType = typeof(T).ToString();
int index = entityType.LastIndexOf('.');
entityType = entityType.Substring(index + 1, entityType.Length - (index + 1));
return helper.Kendo().Grid<
T
>()
.Name(name)
.Groupable()
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.Pageable()
.Selectable(e => e.Mode(GridSelectionMode.Single))
.ToolBar(toolbar => toolbar.Create())
.Columns(columns =>
{
columns.Bound(p => p.CreatedOn).Width(100).Format("{0:dd/MM/yyyy}");
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(170);
})
.Editable(editor => editor
.Mode(GridEditMode.PopUp)
.Window(window => window
.Name("EditorWindow")
.Title("Smartrail Editor")
.Visible(false)
.Modal(true)
.Width(475)
.Render()
)
.TemplateName(entityType + "Editor")
)
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Model(model => model.Id(p => p.ObjectId))
.Events(events => events.Error("onError"))
.Create(x => x.Action("Editor_Create", entityType))
.Read(x => x.Action("Editor_Read", entityType))
.Update(x => x.Action("Editor_Update", entityType))
.Destroy(x => x.Action("Editor_Destroy", entityType))
.ServerOperation(false));
}
}
@(Html.SavitarCRUDGrid<
ReefType
>("Grid1")
.BindTo(Model)
.Columns(columns =>
{
columns.Bound(p => p.Description);
})
)
@(Html.Kendo().Sparkline()
.Name("BatchTimeSpark")
.Type(SparklineType.Column)
.DataSource(ds=>ds
.Read(read => read.Action("GetBatchStats", "Home"))
)
.Series(s=>s
.Column("RunLength")
)
)
@helper RenderConfigPlan()
{
....
<
tr
class
=
"k-header"
>
<
td
>@Html.LabelFor(x => x.minProfit)</
td
>
<
td
>@Html.EditorFor(x => x.minProfit, "Integer")</
td
>
</
tr
>
}