This is a migrated thread and some comments may be shown as answers.

MVC Grid to have edit to custom cshtml

2 Answers 655 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 12 Sep 2017, 11:53 AM

Hi,

We are using Kendo Data Grid, we are trying to edit the record that will go to a new page (cshtml) and passing a parameter like the ID.

Below is the code but it is not working at all. Please advise, TIA.

index.cshtml

@(Html.Kendo().Grid<iOneDistribution.Web.Models.Users.UserViewModel>()
.Name("grid")
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(u => u.UserCode))
.Read(read => read.Action("Users_Read", "Users"))
.Update(update => update.Action("Update", "Users"))
)
.Columns(columns =>
{
columns.Command(c => c.Edit());
columns.Bound(c => c.UserCode);
columns.Bound(c => c.Acronym);
columns.Bound(c => c.IsActive);
columns.Bound(c => c.IsAllowApprove);
columns.Bound(c => c.DefaultCulture);
})
.Pageable()
.Sortable(sortable =>
{
sortable.SortMode(GridSortMode.SingleColumn);
})
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("_UserEdit"))
.Filterable()
.Scrollable()
)

for the _useredit.cshtml

@model iOneDistribution.Web.Models.Users.UserViewModel
<h3>Customized Person edit template</h3>
<br />
@Html.HiddenFor(model => model.UserCode)
<div>
@Html.LabelFor(model => model.Name)
</div>
<div>
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div>
@Html.LabelFor(model => model.UserGroupCode)
</div>
<div>
@*@Html.Kendo().DateTimePickerFor(model => model.BirthDate)
@Html.ValidationMessageFor(model => model.BirthDate)*@
</div>

 

2 Answers, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 1
answered on 13 Sep 2017, 01:37 AM

I found the solution, the cshtml file must be inside the editortemplates folder.

It will not work if you don't put in this folder.

 

0
Stefan
Telerik team
answered on 14 Sep 2017, 08:06 AM
Hello Patrick,

Indeed placing the templates inside the EditorTemplates folder is one of the required steps when using them.

More details can be found in the following article:

http://docs.telerik.com/aspnet-mvc/helpers/grid/templating/editor-templates

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Patrick
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or