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

AutoGeneratingField

1 Answer 58 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Andreas Decke
Top achievements
Rank 1
Andreas Decke asked on 17 Apr 2011, 11:53 AM
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?

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 20 Apr 2011, 04:28 PM
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
Tags
DataForm
Asked by
Andreas Decke
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or