How to set a default value (DateTime.Now) when adding a new record?

4 posts, 1 answers
  1. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 26 Jan 2012 Link to this post

    How do you set a default value on new record - when AddNew is called?  I can't seem to add to the Domain Service metadata - not even sure if that would work. 
    thanks again!

     <telerik:RadButton RenderTransformOrigin="0.5,0.5" Style="{StaticResource HeaderCircleButtonStyle}" Margin="0,0,40,0" 
                              Command="telerik:RadDataFormCommands.AddNew" CommandTarget="{Binding ElementName=matterForm}" Tag="ADD"/ >
                   
  2. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 27 Jan 2012 Link to this post

    Hi Jon,

    You can try handling AddedNewItem event of RadDataForm and set the values you want to be predefined:

    private void DataForm1_AddedNewItem(object sender, AddedNewItemEventArgs e)
            {
                (this.DataForm1.CurrentItem as Club).Name = "NewName";
            }
     
    In you want to perform this operation only in your ViewModel, you can bind CurrentItem property of RadDataForm to a one in this ViewModel, create a new command that will add an item with default values and set this command to be the one for your button. 

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 27 Jan 2012 Link to this post

    Thanks that worked.. But shouldn't you be able to set [Default] in the RIA MetaData class?
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 01 Feb 2012 Link to this post

    Hello Jon,

    We will consider providing support for this attribute.
    Thank you for feedback.  

    Regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top