How to specify only some Fields as Editable in Grid Edit PopUp.

4 posts, 0 answers
  1. Greg Gum
    Greg Gum avatar
    18 posts
    Member since:
    Jun 2009

    Posted 17 Dec 2013 Link to this post

    I have a Kendo Grid with pop-up editing. 

    How do I specify that only some of the columns are editable?  Or that some are read-only?

    I have tried this in the viewmodel, but it doesn't seem to affect the Edit Popup:

    The Display annotation does work however.
              [Display(Name = "Type Id")]
           [Editable(false)]
           public int ReportTypeId { get; set; }

  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1436 posts

    Posted 19 Dec 2013 Link to this post

    Hi Greg,

    Which columns are editable can be specified in the Grid's DataSource configuration using the editable option in the schema model. For example:  
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Model(model => {
            model.Id(p => p.ProductID);
            model.Field(p => p.ProductName).Editable(false);
        })


    Regards,
    Alexander Popov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. John
    John avatar
    1 posts
    Member since:
    Mar 2017

    Posted 24 Mar in reply to Alexander Popov Link to this post

    Hi Alexander

    i am trying to do the same thing with .net core version and is not working....

    Do i have to use template?

     

    this is my Index.cshtml

    @(Html.Kendo().Grid<PriceProject.Models.PricesModels.Category>()
            .Name("Categories")
            .Columns(columns =>
            {
                columns.Bound(c => c.ID);
                columns.Bound(c => c.CategoryName);
                columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
            })
            .ToolBar(toolbar =>
            {
                toolbar.Create().Text("New Category");
                toolbar.Save();
            })
            .Editable(editable => editable.Mode(GridEditMode.PopUp))
            .Pageable()
            .Navigatable()
            .Sortable()
            //.Scrollable()
            .DataSource(dataSource => dataSource
                .Ajax()
                .Batch(true)
                .ServerOperation(true)
                .Model(model =>
                {
                    model.Id(p => p.ID);
                    model.Field(p => p.ID).Editable(false);
                    model.Field(p => p.CategoryName).Editable(true);
                    model.Field(p => p.UserID).DefaultValue(1).Editable(false);

                })
                .Read(read => read.Action("GetCategories", "Categories"))
                .Create(create => create.Action("Create", "Categories"))
                .Update(update => update.Action("Edit", "Categories"))
                .Destroy(update => update.Action("Delete", "Categories"))
                .PageSize(10)
            ).Deferred()
    )

  4. Stefan
    Admin
    Stefan avatar
    1288 posts

    Posted 28 Mar Link to this post

    Hello John,

    I was not able to reproduce the same issue on my end. Still, I will make an additional investigation to ensure that the Core version is not causing unexpected issues.

    I can suggest checking the following example how to make a column editable based on a condition. If the column has to be non-editable all of the time, the function can return false in all scenarios:

    http://docs.telerik.com/aspnet-mvc/helpers/grid/how-to/editing/conditionally-editable-columns

    I hope this will help to achieve the desired result.

    Regards,
    Stefan
    Telerik by Progress
    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.
Back to Top