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

AddNewItem opens editTemplate instead of NewItemTemplate

6 Answers 75 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
peter
Top achievements
Rank 1
peter asked on 16 Jul 2012, 10:13 AM
Hi i have a dataform and some buttons outside of the dataform which are used to open the dataform in the relevant mode. My problem is my add button opens the dataform in the edittemplate instead of the newitemtemplate.

This is my xaml for the dataform

<Telerik:RadDataForm CurrentItem="{Binding STAMemberDetailsReportViewDTO,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnDataErrors=True,ValidatesOnNotifyDataErrors=True}"
                           CommandButtonsVisibility="Cancel,Commit"
                           x:Name="_DetailForm" Header="Static Data - Member Details" 
                           AutoGenerateFields="False" VerticalContentAlignment="Stretch" 
                           HorizontalContentAlignment="Stretch" 
                           NewItemTemplate="{StaticResource memberDetailsNewItemTemplate}">

I have seperate templates for the newitemtemplate and edittemplate. This is my code behind which opens the relevant template;

private void ReceiveMessage(MessageArguments action)
{
    switch (action.Command)
    {
        case MessageCommand.STAMemberAddDetailFormWindow:
            STAMemberDetailViewModel vm = new STAMemberDetailViewModel();
            _DetailForm.CurrentItem = null;
            _DetailForm.ItemsSource = vm.STAMemberDetailsReportViewDTOs;
            _DetailForm.AutoEdit = true;
            _DetailForm.AddNewItem();
            break;
        case MessageCommand.STAMemberEditDetailFormWindow:
            _DetailForm.BeginEdit();
            break;
    }
}

Can anyone see why my Add button will always open the dataform using the edittemplate. I have also tried changing the "AutoEdit" property to false, that didnt work either. Thanks

6 Answers, 1 is accepted

Sort by
0
peter
Top achievements
Rank 1
answered on 17 Jul 2012, 02:59 PM
Hi does anyone know what i can do to get this to work?
0
Ivan Ivanov
Telerik team
answered on 18 Jul 2012, 11:18 AM
Hello,

We have tested this but without any success of reproducing the reported issue. Would you please check whether by any chance BeginEdit() is not invoked after AddNewItem()? In case the issue persists, please feel free to send us a sample project that demonstrates this.

Kind regards,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Michele
Top achievements
Rank 2
answered on 05 Oct 2012, 03:15 PM
Hello Ivan I'm in the same situation.... I've checked and no BeginEdit is called... what can I check to spot the problem?
Thanks
0
Ivan Ivanov
Telerik team
answered on 09 Oct 2012, 08:15 AM
Hello Paolo,

Would it be possible for you to isolate this issue in a sample project, so that we can test it on our side? We have already tried to test this in accordance to the previous client's report, but unfortunately without any success. You can send us the project through our support ticket system.

All the best,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Michele
Top achievements
Rank 2
answered on 09 Oct 2012, 08:23 AM
Hello,
I've just spotted a possible cause... I use the Implicit Theme and if I comment out the RadDataFormStyle it works.... in the specific I got a visual studio message on
<ControlTemplate x:Key="RadDataFormTemplate" TargetType="controls:RadDataForm">
      <Border x:Name="PART_RootElement"  BorderBrush="{TemplateBinding BorderBrush}"  BorderThickness="{TemplateBinding BorderThickness}">
          <i:Interaction.Behaviors>
              <ei:DataStateBehavior Binding="{Binding Mode, RelativeSource={RelativeSource TemplatedParent}}" Value="ReadOnly" TrueState="ReadOnly" FalseState="Edit"/>
          </i:Interaction.Behaviors>
          <VisualStateManager.CustomVisualStateManager>
              <ei:ExtendedVisualStateManager/>
          </VisualStateManager.CustomVisualStateManager>


telling that a value of type 'DataStateBehavior' cannot be added to a collection  or dictionary of type 'BehaviorCollection'

I'm using System.Windows.Interactivity.dll version 5.0.5.0...can this be the problem?
Thank
0
Ivan Ivanov
Telerik team
answered on 12 Oct 2012, 10:33 AM
Hi Paolo,

I have prepared a similar project on my side and it seems to be working fine with our latest version. However, I strongly doubt that this issue has anything to do with VisualStates. I have attached my project for your reference. May I ask you to send us a sample project that demonstrates this issue, or at least the style that you suspect to be the problem's source.

Kind regards,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

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