Dataform - should Telerik controls respect DataFormMode?

7 posts, 0 answers
  1. Tom
    Tom avatar
    44 posts
    Member since:
    Jun 2007

    Posted 13 Sep 2009 Link to this post

    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?

  2. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 16 Sep 2009 Link to this post

    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.
  3. Tom
    Tom avatar
    44 posts
    Member since:
    Jun 2007

    Posted 16 Sep 2009 Link to this post

    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
  4. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 23 Sep 2009 Link to this post

    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.
  5. Nikolay
    Admin
    Nikolay avatar
    3997 posts

    Posted 23 Sep 2009 Link to this post

    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.
  6. Tom
    Tom avatar
    44 posts
    Member since:
    Jun 2007

    Posted 25 Sep 2009 Link to this post

    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;  
                }  
            } 
  7. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 01 Oct 2009 Link to this post

    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.
Back to Top