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

AutoGeneratingField

3 Answers 82 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 10 Jun 2011, 12:27 PM
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

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 16 Jun 2011, 09:03 AM
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
0
Clinton
Top achievements
Rank 1
answered on 20 Jun 2011, 05:23 AM
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
0
Pavel Pavlov
Telerik team
answered on 21 Jun 2011, 02:46 PM
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
Tags
DataForm
Asked by
Andreas Decke
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Clinton
Top achievements
Rank 1
Share this question
or