GridEditMode.PopUp Editing Problems MVC 6

5 posts, 0 answers
  1. fran
    fran avatar
    1 posts
    Member since:
    Jan 2016

    Posted 22 Jan Link to this post

    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...

     

     

  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 26 Jan Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Lo
    Lo avatar
    2 posts
    Member since:
    May 2014

    Posted 01 Dec Link to this post

    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.
  5. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 02 Dec Link to this post

    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.
  6. Lo
    Lo avatar
    2 posts
    Member since:
    May 2014

    Posted 02 Dec in reply to Rosen Link to this post

    Hi Rosen,

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

Back to Top
UI for ASP.NET MVC is VS 2017 Ready