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

Form is always readonly?

2 Answers 69 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 14 Aug 2012, 03:23 PM
I have a RadDataForm on which some DataFormDataField fields seemed to be read-only.

Using Snoop, I discovered that the form's mode is ReadOnly.

Now here's the thing.  I had AutoEdit="True" in the xaml.  I've tried setting AutoEdit and calling BeginEdit() in the constructor, and in DataContextChanged, both, and neither seems to make any difference.  Both in the constructor and in DataContextChanged, CanBeginEdit is false.

What could be going on that would cause CanBeginEdit to be false?

The form is bound to its DataContext, via CurrentItem="{Binding Path=.}"

2 Answers, 1 is accepted

Sort by
0
Jeff
Top achievements
Rank 1
answered on 14 Aug 2012, 06:00 PM
Two observations:

First, by explicitly embedding a TextBox as the content for a DataFormDataField, you can bypass this problem.  That is, instead of:

<telerik:DataFormDataField
    DataMemberBinding="{Binding Quantity}"
    />
do this:
<telerik:DataFormDataField>
    <TextBoxText="{Binding Quantity}"/>
</telerik:DataFormDataField>

That's not really much of a solution, though.  It works because we're using non-telerik data fields that ignore whether the form is in readonly or edit mode.

My best guess at the real problem is that we're binding CurrentItemProperty to the viewmodel in the xaml, at a point at which the viewmodel hasn't yet been set.  What works, and seems to be the correct solution is to bind CurrentItemProperty in DataContextChanged.  If I do this, and have AutoEdit="True", the form is in edit mode, when it opens.
0
Ivan Ivanov
Telerik team
answered on 15 Aug 2012, 02:42 PM
Hello Jeff,

There are few other factors that affect a fields IsReadOnly state, aside from RadDataForm's Mode setting. I presume RadDataForm's data engine considers these properties to be ReadOnly properties. Would you please check for any noticeable reasons for this in their definition? In case that the issue persists, would it be possible for you to send us a sample project that we could debug on our side?

All the best,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
DataForm
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jeff
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or