AutoGeneratingField

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

    Posted 10 Jun 2011 Link to this post

    Hello,
    my code in AutoGeneratingField:

    if (e.PropertyName.Equals("RssPolitikCount"))
    {
      e.DataField.FontWeight = FontWeights.Bold;
      RadNumericUpDown upDown = new RadNumericUpDown();
      upDown.NumberDecimalDigits = 0;
      upDown.Width = 60;
      upDown.HorizontalAlignment = HorizontalAlignment.Left;
      Binding b = new Binding("RssPolitikCount");
      b.Mode = BindingMode.TwoWay;
      upDown.SetBinding(RadRangeBase.ValueProperty, b);
      e.DataField.Content = upDown;
    }

    the RDF is AutoEdit = false, normally is the Control (Textbox, ComboBox) IsReadOnly = true.
    The upDown is allways enabled.

    Please, how can i do for the upDown to IsReadOnly = true in Mode= RadDataFormMode.ReadOnly
    and IsReadOnly=false in Mode = RadDataFormMode.Edit

    thanks
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 16 Jun 2011 Link to this post

    Hi Richard ,

    I am attaching a small demo to illustrate how this can be achieved .

    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
  4. Clinton
    Clinton avatar
    22 posts
    Member since:
    May 2011

    Posted 20 Jun 2011 Link to this post

    Hey there,
    Great solution so far, however, I'd like to use the AutoGeneratingFieldEventArgs to define the Control Type, such as TextBox or some Framework element.

    I understand that this is generally done in Resources with a DataTemplate, however, our product doesn't use any XAML to be able to define the DataTemplate in.  Our product doesn't use much in the way of DataBinding, due to our data and layout being Dynamic.  It is challenging.

    void MWDataFormAutoGeneratingField(object sender, AutoGeneratingFieldEventArgs e)
    {
        foreach (MWDataField mwDataField in MWDataFields)
        {
            if (e.PropertyName.Equals(mwDataField.FieldName))
            {
                e.DataField.Label = mwDataField.Text;
     
                if (mwDataField.ControlType.Equals("CheckBox"))
                {
                    e.PropertyType = typeof (DataFormCheckBoxField);
                }
                if (mwDataField.ControlType.Equals("TextBox"))
                {
                    RadToggleButton thisone = new RadToggleButton();
                    e.DataField.Content = thisone;
                }
                if (mwDataField.ControlType.Equals("Date"))
                {
                    e.PropertyType = typeof (DataFormDateField);
                }
            }
        }
    }


    This is a test of things that I am playing with to get an understanding.  At compile time, the DataForm doesn't know what it's DataFields will be, but these are stored as MWDataField which holds all the information to create the DataForm.

    In this example, the RadToggleButton is created however, I wasn't sure how to populate the content of the ToggleButton without using DataBinding via a Converter.

    Any thoughts or help is appreciated.

    Clinton
  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 21 Jun 2011 Link to this post

    Hi Clinton,

    I am not sure I understand . You can actually use databinding and converter , without any XAML .
    There is no problem in creating a Binding runtime  and setting a converter to it.

    Greetings,
    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
Back to Top