Conditional binding properties...

2 posts, 0 answers
  1. Dietmar
    Dietmar avatar
    15 posts
    Member since:
    May 2012

    Posted 06 Jul 2015 Link to this post

    Hello,

    i run into a problem about conditional binding properties. I want certain properties only writeable on creating an entity, but not on editing. Generally i can fix it on server side by just adding code to check it or just not bind some properties. But how i can solve this on client side? Let's take the following example:

    Data model ->

    public classs MyDataModel
    {
        [ScaffoldColumn(false)]
        public long Id { get; set; }
     
        [Required(AllowEmptyStrings = false)]
        [StringLength(255)]
        [DisplayName("Title")]
        public string Title { get; set; }
     
        [Required(AllowEmptyStrings = false)]
        [StringLength(255)]
        [DisplayName("Description")]
        public string Description { get; set; }
     
        [Required(AllowEmptyStrings = false)]
        [DisplayName("Type")]
        [DefaultValue(1)]
        public int TypeOfSomething { get; set; }
    }

     

    So "TypeOfSomething" should be only writeable on creating the entity. On later editing it should be read only. There is an interesting approach in this comment http://www.codethinked.com/aspnet-mvc-think-before-you-bind/comment-page-1#comment-3933, but i don't see any way to realize this with the Telerik Grid.
    Maybe one of you guys have an idea or some hints for achieving this on client side with the Telerik Grid.

     thanks & regards

  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1443 posts

    Posted 08 Jul 2015 Link to this post

    Hello Dietmar,

    The Kendo UI Model fields can be specified either as editable or non-editable, however allowing editing only when the items are new is not supported. You can achieve similar behavior by subscribing to the Grid's edit event. Once the event is triggered you can check the Model's isNew method and based on that disable certain editors or closing the cell (if InCell editing mode is used).

    Regards,
    Alexander Popov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top