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

Problem with Editable GridEditMode.PopUp

1 Answer 268 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pablo
Top achievements
Rank 1
Pablo asked on 19 Jul 2014, 07:05 PM
Hi,
I have this code in my page

@(Html.Kendo().Grid<LibroDinamico.Models.LibroViewModel>()
        .Name("gridLibros")
        .Columns(columns =>
        {
            columns.Bound(c => c.Titulo);
            columns.Command(command => { command.Edit(); command.Destroy(); });
        })
        .Scrollable()
        .ToolBar(toolbar => toolbar.Create())
        .Editable(editable =>
        {
            editable.Mode(GridEditMode.PopUp);
        })
        .ColumnMenu(p => p.Columns(false))
        .Filterable().Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
        .Sortable(sortable => sortable.AllowUnsort(false))
        .Pageable(pageable => pageable
        .Refresh(true)
        .PageSizes(true)
        .PageSizes(new[] { 5, 10, 25, 50 }))
        .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(10)
                .Model(model =>
                {
                    model.Id(p => p.Id);
                    model.Field(p => p.Id).Editable(false);
                })
                .Create(create => create.Action(MVC.Libro.ActionNames.Create, MVC.Libro.Name))
                .Read(read => read.Action(MVC.Libro.ActionNames.GetLibros, MVC.Libro.Name))
                .Update(update => update.Action(MVC.Libro.ActionNames.Edit, MVC.Libro.Name))
                .Destroy(destroy => destroy.Action(MVC.Libro.ActionNames.Delete, MVC.Libro.Name))
        )
      )  
With this ViewModel    

public class LibroViewModelwith 
    {
        public int Id { get; set; }
        public string Titulo { get; set; }
        public DateTime Creado { get; set; }
        public DateTime Modificado { get; set; }
    }

When I click in Add a new row the popup appears with all the properties of the view model, but I dont want to show all this properties, I want only to present the Titulo. How I can do this. 
Thanks



















1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 21 Jul 2014, 10:52 AM
Hello Pablo,


By design all model fields are shown in the PopUp editor. There a multiple resolutions to the current issue:
  • Include only the required fields for the Grid in the currently used ViewModel
  • Use the edit event handler in order to access the editor container (e.container parameter) and hide the unnecessary editor inputs.
  • Define a custom PopUp editor as demonstrated in the following Code Library.

I hope this information helps.

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Pablo
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or