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

Conditional binding properties...

1 Answer 231 Views
Grid
This is a migrated thread and some comments may be shown as answers.
KRichter
Top achievements
Rank 1
KRichter asked on 06 Jul 2015, 08:26 AM

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

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 08 Jul 2015, 07:34 AM
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
Tags
Grid
Asked by
KRichter
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or