AutoGeneratingField

2 posts, 0 answers
  1. Andreas Decke
    Andreas Decke avatar
    25 posts
    Member since:
    Oct 2007

    Posted 17 Apr 2011 Link to this post

    Hello,

    i work with DataAnnotations in my InfoClass:

    public partial class SDLmedia_ComputerMonitor
    {
      internal sealed class SDLmedia_ComputerMonitorMetaData
      {
        [Display(Order = 0, Name = "ID:", Description = "Die Indentifikation des Monitors.")]
        public int MonitorID { get; set; }
     
        [Display(Order = 1, Name = "ComputerId:", Description = "Die Indentifikation des Computers.")]
        public int ComputerID { get; set; }
     
        [Display(Order = 2, Name = "Bezeichnung:", Description = "Die Bezeichnung des Monitors.")]
        [Required(ErrorMessage = "Eine Bezeichnung wird erwartet!")]
        [StringLength(30, ErrorMessage = "Max. 50 Zeichen!")]
        public string Title { get; set; }
     
        [Display(Order = 3, Name = "Hersteller:", Description = "Der Hersteller des Monitors")]
        [Required(ErrorMessage = "Hersteller wird erwartet!")]
        [StringLength(30, ErrorMessage = "Max. 50 Zeichen!")]
        public string Manufacturer { get; set; }
     
        [Display(Order = 4, Name = "Typ:", Description = "Um welche Art von Monitor handelt es sich(LCD,LED).")]
        [Required(ErrorMessage = "Monitortyp wird erwartet!")]
        public string Screentype { get; set; }
     
        [Display(Order = 5, Name = "Display:", Description = "Die Größe des Displays in Zoll.")]
        [Required(ErrorMessage = "Displaysize wird erwartet!")]
        [Range(10, 100, ErrorMessage = "Displaysize sollte zwischen 10-100 Zoll liegen!")]
        public int? DisplaySize { get; set; }
     
        [Display(Order = 6, Name = "Grafik-Port:", Description = "Schnittstelle über die der Monitor angeschlossen werden kann.")]
        [Required(ErrorMessage = "Ein Grafik-Anschluss wird erwartet!")]
        public string Graphicsport { get; set; }
     
        [Display(Order = 7, Name = "Servicetag:", Description = "Das Servicetag des Monitors.")]
        public string Servicetag { get; set; }
     
        [Display(Order = 8, Name = "Info:", Description = "Informationen zu diesem Monitor.")]
        public string Description { get; set; }
     
        [Display(Order = 9, Name = "Erstellt am:", Description = "Geben Sie eine Firma an.")]
        public DateTime? CreatedDate { get; set; }
     
        [Display(Order = 10, Name = "Erstellt von:", Description = "Geben Sie eine Firma an.")]
        public string CreatedByUser { get; set; }
     
        [Display(Order = 12, Name = "Preis:", Description = "Der Preis des Monitors.")]
        [Required(ErrorMessage = "Ein Preis wird erwartet!")]
        public decimal? Price { get; set; }
     
      }
    }

    when  use  AutoGeneratingField is my Order not correct.

    private void DataFormMonitor_AutoGeneratingField(object sender, AutoGeneratingFieldEventArgs e)
    {
      try
      {
        if (e.PropertyName.Equals("ComputerID"))
        {
          e.DataField.Visibility = Visibility.Collapsed;
        }
        if (e.PropertyName.Equals("MonitorID"))
        {
          e.DataField.IsEnabled = false;
        }
        if (e.PropertyName.Equals("Screentype"))
        {
          e.DataField = new DataFormComboBoxField
                          {
                            Label = "Type:",
                            ItemsSource = Monitortypes.GetMonitortypes(),
                            DisplayMemberPath = "Name",
                            SelectedValuePath = "Value",
                            DataMemberBinding = new Binding("Screentype") { Mode = BindingMode.TwoWay }
                          };
        }
        if (e.PropertyName.Equals("Graphicsport"))
        {
          e.DataField = new DataFormComboBoxField
                          {
                            Label = "Anschluss:",
                            ItemsSource = Grafikports.GetGrafikports(),
                            DisplayMemberPath = "Name",
                            SelectedValuePath = "Value",
                            DataMemberBinding = new Binding("Graphicsport") { Mode = BindingMode.TwoWay }
                          };
        }
        if (e.PropertyName.Equals("DisplaySize"))
        {
        }
        if (e.PropertyName.Equals("Price"))
        {
          e.DataField.DataMemberBinding = new Binding("Price") { Mode = BindingMode.TwoWay, StringFormat = "{0:C}" };
        }
      }
      catch (Exception exc)
      {
        Error.CreateNew(exc, ErrorTitle);
      }
    }

    my problem or has RadDataForm a problem?
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 20 Apr 2011 Link to this post

    Hi Richard Crowley,

    I am trying to reproduce the erroneous behavior here but with no success so far.
    I have copy/pasted the code for your class. The single change I made was to replace the Internal modifier with "Public". Bound it to the current item of RadDataForm and to me it seems the order attribute is working just fine.

    Am I missing something ?

    All the best,
    Pavel Pavlov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top