AddNewItem opens editTemplate instead of NewItemTemplate

7 posts, 0 answers
  1. peter
    peter avatar
    37 posts
    Member since:
    Feb 2011

    Posted 16 Jul 2012 Link to this post

    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
  2. peter
    peter avatar
    37 posts
    Member since:
    Feb 2011

    Posted 17 Jul 2012 Link to this post

    Hi does anyone know what i can do to get this to work?
  3. DevCraft banner
  4. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 18 Jul 2012 Link to this post

    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.

  5. Paolo
    Paolo avatar
    423 posts
    Member since:
    Jun 2009

    Posted 05 Oct 2012 Link to this post

    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
  6. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 09 Oct 2012 Link to this post

    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.

  7. Paolo
    Paolo avatar
    423 posts
    Member since:
    Jun 2009

    Posted 09 Oct 2012 Link to this post

    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
  8. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 12 Oct 2012 Link to this post

    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.

Back to Top
DevCraft banner