Calculated field

2 posts, 0 answers
  1. Dima
    Dima avatar
    50 posts
    Member since:
    Feb 2012

    Posted 07 Jan 2015 Link to this post

    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;
            }
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 09 Jan 2015 Link to this post

    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.

     
Back to Top