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

RadDataForm uses MetaData Annotations?

21 Answers 329 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Ben Hayat
Top achievements
Rank 2
Ben Hayat asked on 17 Mar 2011, 01:27 AM
Does DataForm take advantage of the Display Annotations created in the RIA Services MetaData?
I have all my fields populated with Display attributes as one central location which SL DataForm takes advantage. But I really want to switch over to RadDataForm. :-)

21 Answers, 1 is accepted

Sort by
0
Herr
Top achievements
Rank 2
answered on 17 Mar 2011, 10:48 AM
I just downloaded Q1 2011 and it seems like RadDataForm does NOT respect DiplayAttributes.
That's why I stay with the toolkit DataForm... :-(
0
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 17 Mar 2011, 11:02 AM
it seems to respect "Description" but not "Name"
0
Ben Hayat
Top achievements
Rank 2
answered on 17 Mar 2011, 02:44 PM
Ah, what a bummer!
Thanks Michael & David;

I also need to test it out to see if we can use/insert the new MaskedEditBox and other controls from SL, like checkbox inside of the RadDataForm.

It would be good to get a documentation that points out what the limitations are in this version.
..Ben
0
Ron Frick
Top achievements
Rank 2
answered on 17 Mar 2011, 04:28 PM
I will confirm the Description is the only thing it considers, which is a bummer becasue it is a very nice control.  The great thing about the SL version is being able to auto generate fields and control that behavior from the metadata. This should be added to the next release for sure.

Just so that its transparent....I would like to be able to use all of the annotations similar to this.

 

[Display(Name = "Last Name",
                    Description = "Ex: John", Order = 3,
                      AutoGenerateField = true)]
         public string cust_lname { get; set; }
0
Ron Frick
Top achievements
Rank 2
answered on 17 Mar 2011, 05:39 PM
This is a side by side of MS version to Telerik using auto generate. I am using data annotations like order and name. As you can see we are missing some things that MS takes into account. Data annotation being one, but also some of the object's properties like "Entity Conflict" and "Has Validation Errors".  These properties should not be auto generated.

see atached

this is the only thing in the code behind
CustomerDataFromRad.ItemsSource = customerDomainDataSource.DataView;
CustomerDataFormMS.ItemsSource = customerDomainDataSource.DataView;
0
Ben Hayat
Top achievements
Rank 2
answered on 17 Mar 2011, 07:21 PM
I think the control looks very good for V1. Hopefully by Q2 they'll add the features that MSFT version has.

I'd like to hear team's comments on the future plan.
..Ben
0
Ron Frick
Top achievements
Rank 2
answered on 17 Mar 2011, 07:38 PM
I agree...Q1 Overall is great, and congrats to the team for getting so much out.
0
Gonzalo
Top achievements
Rank 2
answered on 17 Mar 2011, 09:21 PM
I second that. Wish to see at least the features in MSL. Take care and cheers. Q1 is looking great even now.
0
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 20 Mar 2011, 03:56 PM
the control is also not respecting the autogenerate=false data annotation
this is a very important one
0
Ron Frick
Top achievements
Rank 2
answered on 20 Mar 2011, 04:45 PM
I agree very cool feature to be able to turn the auto gen off and on.  I love how the annotation changes what gets displayed in the data sources window in the IDE. It is a great time saver.

I started a feature request and they have assured me that the neccessary changes are going to be in the next release, and might even be in the next internal build.

0
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 21 Mar 2011, 12:13 AM
Heres a stop-gap until it is corrected in the distributed controls
it alters the dataform to repect "Name" and "AutoGenerate" data annotations.

Private Sub dfDateRange_AutoGeneratingField(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs) Handles dfDateRange.AutoGeneratingField
    Dim thetype As System.Type = dfDateRange.CurrentItem.GetType
    Dim Info As System.Reflection.PropertyInfo = thetype.GetProperty(e.PropertyName)
    If Info IsNot Nothing Then
        Dim attribs As Object() = Info.GetCustomAttributes(GetType(ComponentModel.DataAnnotations.DisplayAttribute), False)
        If attribs IsNot Nothing AndAlso attribs.Count > 0 Then
            Dim Attrib As ComponentModel.DataAnnotations.DisplayAttribute = attribs(0)
            If Attrib.GetAutoGenerateField = False Then
                e.Cancel = True
                Exit Sub
            End If
            If Attrib.GetName IsNot Nothing AndAlso Attrib.GetName <> "" Then
                e.DataField.Label = Attrib.Name
            End If
        End If
    End If
End Sub

thanks
dco
0
Accepted
Pavel Pavlov
Telerik team
answered on 21 Mar 2011, 10:59 AM
Hi guys ,

Indeed the workaround suggested by David will do the trick until next Friday . We are testing the new code regarding data annotations  and will include it in a few days.

Kind regards,
Pavel Pavlov
the Telerik team
0
Ben Hayat
Top achievements
Rank 2
answered on 21 Mar 2011, 01:15 PM
Sounds Excellent Pavel!

Thanks!
..Ben
0
Ben Hayat
Top achievements
Rank 2
answered on 22 Mar 2011, 01:14 AM
Pavel, do you think it's safe to assume that the annotation will be completed by Q1 SP1?
Do you think I should start converting the SL DataForm to RADDataform starting now?

Secondly, is it OK to use the new RadMaskedTextInput controls like in the following format inside of the form as Manual defention:

                        <telerik:DataFormDataField.Content>
                                <telerik:RadMaskedTextInput Mask="lllllllll" />
                            </telerik:DataFormDataField.Content>
                        </telerik:DataFormDataField>

Thanks!
..Ben
0
Pavel Pavlov
Telerik team
answered on 24 Mar 2011, 10:46 AM
Hi guys ,
A quick update :

A support for the following DataAnnotations attributes was included and will be present in the very next internal build :

Display.Order
Display.Description
Display.AutoGenerateField
Display.Name

Best wishes,
Pavel Pavlov
the Telerik team
0
Rob
Top achievements
Rank 1
answered on 29 Mar 2011, 05:48 PM
This wasn't listed in the internal build release notes for the 3/28/11 internal build.
0
Ben Hayat
Top achievements
Rank 2
answered on 29 Mar 2011, 06:11 PM
Hi guys ,
A quick update :

A support for the following DataAnnotations attributes was included and will be present in the very next internal build :


Display.Order

Display.Description
Display.AutoGenerateField
Display.Name

Pavel, did the above make it to the new internal build as of 3/28?
0
Pavel Pavlov
Telerik team
answered on 30 Mar 2011, 03:20 PM
Hi Ben ,

Yes id did .
* Please heave in mind that attributes will be respected  only by the auto-generated fields.
If you define your own custom fields , you have the freedom to set name , description etc. directly on the fields.

Kind regards,
Pavel Pavlov
the Telerik team
0
Ben Jones
Top achievements
Rank 1
answered on 23 Jan 2012, 10:15 AM
Hi Pavel,

Does this support cover strings loaded thorugh resource files?

i.e.
[Display(ResourceType=typeof(Resources.ExternalResources.Strings), Name="Description", Description = "Description", AutoGenerateField = true)]

It does not seem to work for me using the above example (Resources.ExternalResources.Strings is a resource class in another assembly)

Kind Regards

Ben
0
joseph
Top achievements
Rank 1
answered on 25 Jan 2012, 05:33 AM
Thanks David!

I used your example to iterate the fields on the entire data form and set the IsEnabled property to match the value in the EditableAttribute data annotation.

public void AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
       {
           System.Type rdfType = (sender as RadDataForm).CurrentItem.GetType();
           System.Reflection.PropertyInfo propertyInfo = rdfType.GetProperty(e.PropertyName);
           if (propertyInfo != null)
           {
               object[] EditableAttribute = propertyInfo.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.EditableAttribute), false);
               if (EditableAttribute != null && EditableAttribute.Length > 0)
               {
                   if ((EditableAttribute[0] as System.ComponentModel.DataAnnotations.EditableAttribute).AllowEdit == false)
                   {
                       e.DataField.IsEnabled = false;
                   }
               }
           }
0
Ivan Ivanov
Telerik team
answered on 26 Jan 2012, 11:01 AM
Hi Ben,

I believe that you should not be experiencing such problems with RadDataForm. Would you please open a support ticket, sending us a small runnable project, so that we could debug it on our side and give you an appropriate solution.

Regards,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
DataForm
Asked by
Ben Hayat
Top achievements
Rank 2
Answers by
Herr
Top achievements
Rank 2
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
Ben Hayat
Top achievements
Rank 2
Ron Frick
Top achievements
Rank 2
Gonzalo
Top achievements
Rank 2
Pavel Pavlov
Telerik team
Rob
Top achievements
Rank 1
Ben Jones
Top achievements
Rank 1
joseph
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or