MVC Grid modal edit item

2 posts, 0 answers
  1. Andrés
    Andrés avatar
    6 posts
    Member since:
    Aug 2015

    Posted 24 Sep 2015 Link to this post

    Hi, I've been working with telerik mcv grid, i've used a modelview to pass the data to the controller. Now i want the user to be available to edit the row information but every time the user presses the edit button on the grid the modal window shows the item id which is not suposed to be displayed

     This is the modelview 

    public class EmpleadoViewModel
        {
            public int EmpleadoID { get; set; }
             
            [Required]
            public String Nombre { get; set; }
     
            [Required]
            public String Email { get; set; }
     
            [Required]
            public String Activo { get; set; }
     
            [Required]
            public String Role { get; set; }
        }

     

     This is the grid config

    @(Html.Kendo().Grid<EmpleadoViewModel>()
                   .Name("people_grid")
                   .Columns(columns =>
                   {
                       columns.Bound(e => e.Nombre).Title("Nombres").HeaderHtmlAttributes(new { style = "text-align:center" });
                       columns.Bound(e => e.Email).Title("E-Mail").HeaderHtmlAttributes(new { style = "text-align:center" });
                       columns.Bound(e => e.Activo).Title("Estado").HeaderHtmlAttributes(new { style = "text-align:center" });
                       columns.Bound(e => e.Role).Title("Rol de sitio").HeaderHtmlAttributes(new { style = "text-align:center" });
                       columns.Command(command =>
                       {
                           command.Edit().Text("Editar").HtmlAttributes(new { @class = "sharp", onmouseover = "editBtnPopover(this)", onmouseout="hidePopover(this)" });
                           command.Custom("Deshabilitar").Click("disablePerson").HtmlAttributes(new { @class = "sharp", onmouseover = "disableBtnPopover(this)", onmouseout = "hidePopover(this)" });
     
                       }).Title("Acciones").HeaderHtmlAttributes(new { style = "text-align:center" });
                   })
                   .ToolBar(toolbar =>
                   {
                       toolbar.Create().Text("Nuevo").HtmlAttributes(new { id="new_btn" });
                       
                   })
                   .HtmlAttributes(new { style = "height:550px;" })
                   .Editable(editable =>
                       editable.Mode(GridEditMode.PopUp).Window(window =>
                       {
                           window.Draggable(false);
                           window.Title("ICS: Personas");
                       }))
                   .Scrollable()
                   .Sortable()
                   .Pageable(pageable =>
                   {
                       pageable.Refresh(false);
                       pageable.PageSizes(true);
                       pageable.ButtonCount(5);
                   })
                    
                   .Events(events => events.Change("getSelectedItem"))
                   .DataSource(dataSource => dataSource
                       .Ajax()
                        
                       .PageSize(10)
                       .Model(model =>
                       {
                           model.Id(emp => emp.EmpleadoID);
                           model.Field(emp => emp.EmpleadoID).Editable(false);
                       })
                       .Create(update => update.Action("EditingPopup_Create", "Grid"))
                       .Read(read => read.Action("Read_Alpes_Employees", "Demo"))
                       .Update(update => update.Action("EditingPopup_Update", "Grid"))
                       .Destroy(update => update.Action("EditingPopup_Destroy", "Grid"))
                   )
               )

     

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2033 posts

    Posted 28 Sep 2015 Link to this post

    Hello Andrés,

     

    Please refer to http://www.telerik.com/forums/mvc-grid-modal-edit-item forum thread, where an answer to the same question is posted. 

     

    Regards,
    Boyan Dimitrov
    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
Back to Top