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

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

3 Answers 175 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jon
Top achievements
Rank 1
Jon asked on 26 Jan 2012, 10:09 PM
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"/ >
               

3 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 27 Jan 2012, 09:05 AM
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 >>

0
Jon
Top achievements
Rank 1
answered on 27 Jan 2012, 01:32 PM
Thanks that worked.. But shouldn't you be able to set [Default] in the RIA MetaData class?
0
Maya
Telerik team
answered on 01 Feb 2012, 12:53 PM
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 >>

Tags
DataForm
Asked by
Jon
Top achievements
Rank 1
Answers by
Maya
Telerik team
Jon
Top achievements
Rank 1
Share this question
or