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

Dataform - should Telerik controls respect DataFormMode?

6 Answers 106 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 14 Sep 2009, 04:31 AM
I've got a DataForm with an EditTemplate in which I've placed some RadComboBox and DatePicker controls. All works very nicely, except that the controls are enabled when the form is in ReadOnly mode.

This may or may not be by design, but standard controls like text boxes will automatically be readonly if the form is readonly. The Telerik ones have to be manually located and set withing the ContentLoaded event of the Dataform.

Is there a better way of doing this? Or should it just work?

6 Answers, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 16 Sep 2009, 02:01 PM
Hello Tom,

Thank you for the feedback. As a decision you can bind the ReadOnly property of the RadComboBox and RadDatePicker to the ReadOnly property of the DataForm control, using ElementName binding. Let us know if you need some more information.

Sincerely yours,
Kaloyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tom
Top achievements
Rank 1
answered on 17 Sep 2009, 02:00 AM
Hi Kaloyan,

I had a couple of goes at this but either I'm using the wrong code or its not working.

Could you maybe give me the 1 line example of the binding?

Remember though that the state needs to change when the user enters edit mode on the DataForm, so its not the initial IsReadonly state I need, it has to be based on the form's DataFormMode.

Really, I think this should just work as other controls do without me having to add any special binding.

Thanks,
Tom
0
Kaloyan
Telerik team
answered on 23 Sep 2009, 02:38 PM
Hi Tom,

Thank you for your feedback and suggestions. Unfortunately, it is not possible to configure the control to respect the parent's property as we can not predict what will be the actual type of the parent(DataForm) of the RadComboBox and RadDatePicker. Also, I checked the behavior of the other controls such as TextBox when setting the IsReadOnly property of the DataForm. The result was that they didn't update their state either. As a possible solution to your case you can set the ReadOnlyTemplate property of the DataForm where you can define controls in the appropriate state. Check the code snippet bellow:

  <dataForm:DataForm Width="200" Height="200" x:Name="dataForm" CurrentIndex="0"
            <dataForm:DataForm.EditTemplate> 
                <DataTemplate> 
                    <StackPanel> 
                        <telerikInput:RadDatePicker Width="100" Height="25" /> 
                    </StackPanel> 
                </DataTemplate> 
            </dataForm:DataForm.EditTemplate> 
            <dataForm:DataForm.ReadOnlyTemplate> 
                <DataTemplate> 
                    <StackPanel> 
                        <TextBox Text="Some text" Width="100" /> 
                        <telerikInput:RadDatePicker Width="100" IsReadOnly="True" Height="25" /> 
                    </StackPanel> 
                </DataTemplate> 
            </dataForm:DataForm.ReadOnlyTemplate> 
        </dataForm:DataForm> 
 

Let us know of you need some more inputs or some example regarding this scenario.


Best wishes,
Kaloyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Nikolay
Telerik team
answered on 23 Sep 2009, 02:39 PM
Hi Tom,

Thank you for your feedback and suggestions. Unfortunately, it is not possible to configure the control to respect the parent's property as we can not predict what will be the actual type of the parent(DataForm) of the RadComboBox and RadDatePicker. Also, I checked the behavior of the other controls such as TextBox when setting the IsReadOnly property of the DataForm. The result was that they didn't update their state either. As a possible solution to your case you can set the ReadOnlyTemplate property of the DataForm where you can define controls in the appropriate state. Check the code snippet bellow:

  <dataForm:DataForm Width="200" Height="200" x:Name="dataForm" CurrentIndex="0"
            <dataForm:DataForm.EditTemplate> 
                <DataTemplate> 
                    <StackPanel> 
                        <telerikInput:RadDatePicker Width="100" Height="25" /> 
                    </StackPanel> 
                </DataTemplate> 
            </dataForm:DataForm.EditTemplate> 
            <dataForm:DataForm.ReadOnlyTemplate> 
                <DataTemplate> 
                    <StackPanel> 
                        <TextBox Text="Some text" Width="100" /> 
                        <telerikInput:RadDatePicker Width="100" IsReadOnly="True" Height="25" /> 
                    </StackPanel> 
                </DataTemplate> 
            </dataForm:DataForm.ReadOnlyTemplate> 
        </dataForm:DataForm> 
 

Let us know of you need some more inputs or some example regarding this scenario.


Best wishes,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tom
Top achievements
Rank 1
answered on 25 Sep 2009, 09:08 AM
Hi Nick,

I've got around it by finding the control when the data form loads its content, checking the data form's EditMode, and setting the controls readonly properties in there.

Its not actually the IsReadOnly property I'm worried about (sorry I may have been unclear on this) - its the DataForm's EditMode. I found that regular text boxes are correctly disabled if the DataForm is not in EditMode, while the RadComboBox's are not.

       void SchoolForm_ContentLoaded(object sender, DataFormContentLoadEventArgs e)  
        {  
            RadComboBox cb = SchoolForm.FindNameInContent("NetworkCombo"as RadComboBox;  
            cb.ItemsSource = NetworkList;  
            RadComboBox cb2 = SchoolForm.FindNameInContent("CNACombo"as RadComboBox;  
            cb2.ItemsSource = CNAList;  
              
            if (e.Mode == DataFormMode.Edit)  
            {  
                cb.IsEnabled = true;  
                cb2.IsEnabled = true;  
            }  
            else 
            {  
                cb.IsEnabled = false;  
                cb2.IsEnabled = false;  
            }  
        } 
0
Kaloyan
Telerik team
answered on 01 Oct 2009, 09:34 AM
Hi Tom,

We are glad that you found a solution for your case.

If you have any other questions do not hesitate to contact us.

Regards,
Kaloyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Tom
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Tom
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or