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

Making a form readonly without disabling it?

10 Answers 1122 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 12 Jun 2014, 10:01 PM
We have a complaint from a customer, and aren't sure of how to deal with it.

The problem is that when we're displaying a RadDataForm with IsEnabled="False", they are unable to select the text on the form and copy it to the clipboard. Which, apparently, is a significant problem for them.

It's an easy enough problem to replicate. You can see it in your example at https://github.com/telerik/xaml-sdk/tree/master/DataForm by simply setting IsEnabledFalse="True" on the RadDataForm.

Is there another simple way of making a form readonly, that doesn't cause this problem?

10 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 17 Jun 2014, 01:55 PM
Hi Jeff,

The IsEnabled property is automatically propagated to the child controls, by the framework itself. Have you considered using RadDataForm in read-only mode instead (Mode=ReadOnly)? In this mode selection for TextBox editors is supported.

Regards,
Ivan Ivanov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Jeff
Top achievements
Rank 1
answered on 22 Sep 2015, 08:04 PM

The product we were working on when I asked this question was shelved, because of new priorities and serious doubts about whether we actually needed it.

 

Now I suddenly have to get it out, brush it off, and fix a couple of issues, so we can show it off at a user conference next week. Number one on the list of issues is this.

 

I've pretty much forgotten everything I knew about WPF, but I'm trying to figure it out, again.

 

I've dug through the UI tree using Snoop, and confirmed that IsEnabled=False for the controls in question. Then, just as an experiment, I hard-coded IsEnabled=True in the XAML declaration for the form. Snoop now indicates that IsEnabled=True for the controls - and they still can't be selected.

 

I vaguely remember having had to change the transparency on a layer that you draw over the top of the form, when the form was disabled, to keep people from interacting with it. Could something like that be in place, that would keep me from selecting the text?

0
Yoan
Telerik team
answered on 23 Sep 2015, 08:05 AM
Hello Jeff,

I am sending you a sample project which demonstrates the approach that my colleague Ivan had suggested - using ReadOnlyTemplate instead of setting IsEnabled=False. In the sample project you will see the difference between the two approaches.

If you need further assistance on this, do not hesitate to contact me again.

Regards,
Yoan
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Jeff
Top achievements
Rank 1
answered on 24 Sep 2015, 08:27 PM

I can see in your sample project the disabled form and the read-only form, and I can see that the fields are selectable, but not editable, in the read-only form which is the behavior I want.

But here's the thing - on digging deeper I'm not sure the form I was talking about is not IsEnabled=false. Or, at least, I can't find the code that's doing it. It is setting its ReadOnlyTemplate, as you suggested. But the fields are still not selectable.

 When I look at the disabled form in your demo in Snoop, I see a Border named "Background_Disabled". When I look at my form I do not. And again, in snoop, the form's IsEnabled flag is true. When I navigate down the UI tree, I see that the grids on the form are enabled, but the individual textBoxes are not.

 Any idea what could be disabling them?

0
Jeff
Top achievements
Rank 1
answered on 24 Sep 2015, 08:41 PM

Never mind. After that bit of exploration, I was able to find the bit of markup that was disabling the fields - we had a style applied.

 

The problem now is that if I remove the style, the fields are editable, despite the template being loaded via the form's ReadOnlyTemplate.

 

Is this something that might have changed, between the version we're using (2012.3.1017.40) and the one your demo uses (2015.2.623.40).

0
Yoan
Telerik team
answered on 29 Sep 2015, 02:49 PM
Hello Jeff,

Indeed, the change is from our side. We had changed the ReadOnly state of some controls. However, in your case the editor, when using the ReadOnlyTemplate is not editable.

Regards,
Yoan
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Jeff
Top achievements
Rank 1
answered on 29 Sep 2015, 03:25 PM

I clearly must be misunderstanding something.  We've been loading a form with only its ReadOnlyTemplate set, yet the TextBoxes could be manipulated - characters entered, deleted, etc., and the ChecklBoxes could be checked and unchecked. Because of this, we had d​isabled them:

<Grid.Resources>
    <Style TargetType="TextBox">
        <Setter Property="IsEnabled" Value="False"/>
    </Style>
    <Style TargetType="CheckBox">
        <Setter Property="IsEnabled" Value="False"/>
    </Style>
</Grid.Resources>
 

This prevented the user from making changes to the fields, but made it impossible to copy the text to the clipboard. I'd thought, from this thread and reading through the version notes, that this might have been fixed in a more recent version.

So this morning, I updated our project to 2015.2.728.40, and removed the above Styles.

 Result? The TextBoxes are still active and can be edited.

 

 

 

 

0
Yoan
Telerik team
answered on 30 Sep 2015, 10:31 AM
Hello Jeff,

This is strange. I had tested the sample project which I sent you with your version - 2012.3.1017.40 and the editors are not editable. Also, they are not editable using our latest version - 2015.2.728.40 . Unfortunately with the supplied information I cannot figure out what is going on. Could you please try to isolate the problem you have in the sample project from my previous reply? Then you can send it to me for further investigation.

Regards,
Yoan
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Jeff
Top achievements
Rank 1
answered on 30 Sep 2015, 09:57 PM
I've found a work-around - I have my style set IsReadOnly=true, instead of IsEnabled=false, for the textboxes.  CheckBoxes don't seem to accept that, so I'm still using IsEnabled=False for them. Which isn't ideal (colors change) but we can live with it.
0
Yoan
Telerik team
answered on 01 Oct 2015, 01:17 PM
Hi Jeff,

I am glad to hear that. If you need further assistance on this, do not hesitate to contact me again.

Regards,
Yoan
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
DataForm
Asked by
Jeff
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Jeff
Top achievements
Rank 1
Yoan
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or