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

Calculated field

1 Answer 209 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dina
Top achievements
Rank 1
Dina asked on 07 Jan 2015, 06:14 PM
Is any way to hide calculated column in edit mode?
I have age calculated then grid read ajax data
      Age = (human.Dateofbirth > DateTime.Now.AddYears(-(DateTime.Now.Year - human.Dateofbirth.Value.Year))) ? (DateTime.Now.Year - human.Dateofbirth.Value.Year) - 1 : DateTime.Now.Year - human.Dateofbirth.Value.Year
       
Column shows age in grid but also appears in pop up edit mode

I know I can catch event and dynamically hide icon just wander if grid can aware of calculated column

in model:
        [ReadOnly(true)]
        [Editable(false)]
        [DisplayName("Age")]
        public int Age
        {
            get;
            set;
        }

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 09 Jan 2015, 02:46 PM

Hello Dima,

Set the Editable option for that field to false in order to make it non editable i.e. readonly

@(Html.Kendo().Grid<KendoMVCWrappers.Models.Person>().Name("people")
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(
            model =>
            {
                model.Id(m => m.PersonID);
                model.Field(field=>field.Name).Editable(false);
        })

Regards,
Petur Subev
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
Dina
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or