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

[Solved] ReadOnly field in telerik asp.net mvc grid

0 Answers 172 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bassam
Top achievements
Rank 1
Bassam asked on 18 Feb 2011, 03:25 PM
<%= Html.Telerik().Grid<GulfUniSystem.ApplicationServices.ViewModels.CoreModule.FacultyViewModel>()
        .Name("FacultiesGrid")
        .DataKeys(keys => keys.Add(k => k.Id))
        .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.ImageAndText))
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Select("_FillData", "Faculties")
                .Insert("_SaveRecord", "Faculties")
                .Update("_SaveRecord", "Faculties")
                .Delete("_DeleteRecord", "Faculties");
        })
        .Columns(columns =>
        {
                columns.Bound(o => o.Name);
                columns.Bound(o => o.Version).ReadOnly(true);
                columns.Command(commands =>
                {
                    commands.Edit().ButtonType(GridButtonType.ImageAndText);
                    commands.Delete().ButtonType(GridButtonType.ImageAndText);
                }).Width(200).Title("Commands");

        })
        .Editable(editing => editing.Mode(GridEditMode.PopUp))
        .ClientEvents(events => events.OnError("onError"))
        .Sortable(sorter => sorter.SortMode(GridSortMode.MultipleColumn))
        .Filterable()
        .Scrollable()
        .Pageable(pager => pager.PageSize(20))
        .Resizable(resizing => resizing.Columns(true))
        .Reorderable(reorder => reorder.Columns(true))
        .Groupable()
        .Selectable()
%>
<script type="text/javascript">
    function onError(e) {
        alert(e.XMLHttpRequest.responseText);
        e.preventDefault();
    }
</script>




------------------
    public class Faculty : DomainEntity
    {
        public virtual string Name { get; set; }
    }
---------------
    public class DomainEntity : Entity
    {
        public virtual int Version { get; set; }
    }

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

        [AcceptVerbs(HttpVerbs.Post)]
        [Transaction]
        [GridAction]
        public ActionResult _SaveRecord(Faculty faculty)
        {
            var actionConfirm = facultyManagementService.SaveOrUpdate(faculty);
            if (!actionConfirm.WasSuccessful)
            {
                return Content(actionConfirm.Message);
            }
            return _FillData();
        }


Hello,

I want to make the Version field not editable,

how to to do it ?

I am using 2010.3.1111.235 version of Telerik mvc 2
Tags
Grid
Asked by
Bassam
Top achievements
Rank 1
Share this question
or