RadDataForm uses MetaData Annotations?

22 posts, 1 answers
  1. Ben Hayat
    Ben Hayat avatar
    892 posts
    Member since:
    May 2008

    Posted 16 Mar 2011 Link to this post

    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. :-)
  2. Herr
    Herr avatar
    23 posts
    Member since:
    Feb 2009

    Posted 17 Mar 2011 Link to this post

    I just downloaded Q1 2011 and it seems like RadDataForm does NOT respect DiplayAttributes.
    That's why I stay with the toolkit DataForm... :-(
  3. DevCraft banner
  4. David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 17 Mar 2011 Link to this post

    it seems to respect "Description" but not "Name"
  5. Ben Hayat
    Ben Hayat avatar
    892 posts
    Member since:
    May 2008

    Posted 17 Mar 2011 Link to this post

    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
  6. Ron Frick
    Ron Frick avatar
    28 posts
    Member since:
    Nov 2009

    Posted 17 Mar 2011 Link to this post

    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; }
  7. Ron Frick
    Ron Frick avatar
    28 posts
    Member since:
    Nov 2009

    Posted 17 Mar 2011 Link to this post

    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;
  8. Ben Hayat
    Ben Hayat avatar
    892 posts
    Member since:
    May 2008

    Posted 17 Mar 2011 Link to this post

    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
  9. Ron Frick
    Ron Frick avatar
    28 posts
    Member since:
    Nov 2009

    Posted 17 Mar 2011 Link to this post

    I agree...Q1 Overall is great, and congrats to the team for getting so much out.
  10. Gonzalo
    Gonzalo avatar
    76 posts
    Member since:
    Oct 2012

    Posted 17 Mar 2011 Link to this post

    I second that. Wish to see at least the features in MSL. Take care and cheers. Q1 is looking great even now.
  11. David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 20 Mar 2011 Link to this post

    the control is also not respecting the autogenerate=false data annotation
    this is a very important one
  12. Ron Frick
    Ron Frick avatar
    28 posts
    Member since:
    Nov 2009

    Posted 20 Mar 2011 Link to this post

    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.

  13. David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 20 Mar 2011 Link to this post

    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
  14. Answer
    Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 21 Mar 2011 Link to this post

    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
  15. Ben Hayat
    Ben Hayat avatar
    892 posts
    Member since:
    May 2008

    Posted 21 Mar 2011 Link to this post

    Sounds Excellent Pavel!

    Thanks!
    ..Ben
  16. Ben Hayat
    Ben Hayat avatar
    892 posts
    Member since:
    May 2008

    Posted 21 Mar 2011 Link to this post

    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
  17. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 24 Mar 2011 Link to this post

    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
  18. Rob
    Rob avatar
    37 posts
    Member since:
    Apr 2008

    Posted 29 Mar 2011 Link to this post

    This wasn't listed in the internal build release notes for the 3/28/11 internal build.
  19. Ben Hayat
    Ben Hayat avatar
    892 posts
    Member since:
    May 2008

    Posted 29 Mar 2011 Link to this post

    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?
  20. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 30 Mar 2011 Link to this post

    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
  21. Ben Jones
    Ben Jones avatar
    12 posts
    Member since:
    Jun 2009

    Posted 23 Jan 2012 Link to this post

    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
  22. joseph
    joseph avatar
    2 posts
    Member since:
    Dec 2010

    Posted 24 Jan 2012 Link to this post

    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;
                       }
                   }
               }
  23. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 26 Jan 2012 Link to this post

    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 >>
Back to Top
DevCraft banner