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

GridEditMode.PopUp Editing Problems MVC 6

4 Answers 218 Views
Grid
This is a migrated thread and some comments may be shown as answers.
fran
Top achievements
Rank 1
fran asked on 22 Jan 2016, 10:36 AM

hi, im using asp.net 5 with MVC 6 and i have 2 problem using GridEditMode.PopUp

----------------------------------------------------- view ----------------------------------------------------------------------------

 @(Html.Kendo().Grid<Organization>()  .Name("grid")

.Columns(columns =>             {                

 columns.Bound(p => p.Name).Title("Name");

columns.Bound(p => p.Email).Title("Email");

 columns.Bound(p => p.Disabled).Title("Disabled").Width(120);                         columns.Command(command => { command.Edit(); command.Destroy(); }).Width(150);             })

.HtmlAttributes(new { style = "height: 550px;" })             

.ToolBar(toolbar => toolbar.Create().Text("Add"))             

.Editable(editable =>{ editable.Mode(GridEditMode.PopUp); editable.TemplateName("Edit"); })             

.Pageable( pageable => pageable .Input(false) .Numeric(false) ) .Filterable().Sortable().Scrollable()          .Events(events => events.Edit("insertPopupCaption"))             

.DataSource(dataSource => dataSource.Ajax().PageSize(11).Events(events => events.Error("grid_error"))

.Model(model =>  {                        

 model.Id(p => p.Id);                         

model.Field(p => p.Name).Editable(false);

model.Field(p => p.Email).Editable(true);                         

model.Field(p => p.Disabled); })

.Create(update => update.Action("Create", "Organization"))

.Read(read => read.Action("GetAll", "Organization"))                

 .Update(update => update.Action("Update", "Organization"))                 

.Destroy(update => update.Action("Delete", "Organization"))     )             )

-----------------------------------------------------------------------------------------------------------------------------------

Problems:

 1- As you can see im using editable.TemplateName("Edit") but this template is never found in the path "/view/Organization/EditorTemplates/Edit.cshtml" the only way to make it works is using the template in the path  "/view/Shared/EditorTemplates/Edit.cshtml" (i have seen projects with mvc5 and this problem never happens)

 

2- if i try to remove the tag editable.TemplateName("Edit");  tring to use the template by default, this template seems to dont have in account the model because  the field NAME "model.Field(p => p.Name).Editable(false);" is set to as not edittable BUT IN THE POPUP IT CAN BE EDITTABLE...

 

 Thanks for your help...

 

 

4 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 26 Jan 2016, 08:03 AM

Hello fran,

 

Straight to your questions:

 

- I'm afraid that I'm not sure what may be causing this issue. Could you please provide a small runnable sample which demonstrate the described behavior. This will allow us to further investigate your case.

 

- Regarding your second question. As you may know the popup edit form uses Html.EditorForModel in order to create the actual edit form template. Thus, there is no way to "externally" influence which field will be rendered as readonly via the DataSource's Model settings. In order to mark any Model property you should use "the standard" way as with any other ASP.NET MVC editor - for example decorating the property with the ReadOnlyAttribute.  

 

Regards,
Rosen
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Lo
Top achievements
Rank 1
answered on 01 Dec 2016, 08:57 AM
Hi,

I'm trying out mvc core with VS2015 and have two problems one of which is also described in this topic, so I'll reply here.


1. I use a custom template and when I press edit the template in shared/Editortemplates is used instead of the one in Home/Editortemplates
2. I use a clienttemplate to join a list of strings so I can display it in one column. This works great until I press add. The error 'Uncaught ReferenceError: Locations is not defined(…)' is then displayed in the log.

I attached a small project to demonstrate the behaviour. I hope you can help me solve these issues.
0
Rosen
Telerik team
answered on 02 Dec 2016, 09:17 AM

Hello Lo,

The first issue is a known problem it is logged here and you can track it progress there.

The second one is most probably due to Locations been undefined when new item instance is created. Therefore, you should make sure the appropriate default value is set. For example (using the sample project):

.Model(mdl => {
    mdl.Id(m => m.Name);
    mdl.Field(m => m.TheList).DefaultValue(new List<string>());
})

Regards,
Rosen
Telerik by Progress
Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
0
Lo
Top achievements
Rank 1
answered on 02 Dec 2016, 10:22 AM

Hi Rosen,

Thanks for the info, and the suggested change in my code works perfectly.

Tags
Grid
Asked by
fran
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Lo
Top achievements
Rank 1
Share this question
or