RadDataForm, CommandButtonsVisibility on empty ObservableCollection

8 posts, 1 answers
  1. Tihomir
    Tihomir avatar
    2 posts
    Member since:
    Oct 2010

    Posted 02 Jun 2011 Link to this post

    Hi,

     

    I wont to hide Delete button on RadDataForm so I define CommandButtonsVisibility.

    If my ObservableCollection has no items RadDataForm shows only Edit button which is disabled. If ObservableCollection has at least one Item the buttons are shown correctly.

    If I removed CommandButtonsVisibility property each buttons are shown correctly it doesn’t matter if I had item in ObservableCollection or not.

     

    Is that a bug or I am wrong somewhere?

    <telerik:RadDataForm x:Name="DataFormSoftwareVersions" ItemsSource="{Binding SoftwareVersions}" AutoGenerateFields="False" CommandButtonsVisibility="Add,Cancel,Commit,Navigation,Edit">
    ...

    Tihomir
  2. Answer
    Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 07 Jun 2011 Link to this post

    Hi Tihomir,

    Please upgrade to the latest internal build and in case there is still a problem  - let me know.

    Kind regards,
    Pavel Pavlov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Clinton
    Clinton avatar
    22 posts
    Member since:
    May 2011

    Posted 15 Jun 2011 Link to this post

    Hi there,

    I have the same problem, and I've updated to the latest internal build v2011.1.606.1040(Dev).

    To replicate, open in Expression Blend, put in

    CommandButtonsVisibility="Add,

    Then add 

     Edit" />

    If you close the project and re-open it, it loads fine.  The problem for me and our project, is that the data that defines the DataForm is turning the buttons on and off dynamically.  And by doing this, the control fails.

     

    private void AssignFlag(DataFormCommandButtonsVisibility flag, bool assign)
    {
        if (assign)
        {
            CommandButtonsVisibility = CommandButtonsVisibility == null ? flag : CommandButtonsVisibility | flag;
        }
        else if (CommandButtonsVisibility != null && CommandButtonsVisibility.Value.HasFlag(flag))
        {
            CommandButtonsVisibility = CommandButtonsVisibility & ~flag;
        }
    }
    public bool ShowAddButton
    {
        set
        {
            AssignFlag(DataFormCommandButtonsVisibility.Add, value);
        }
    }
    public bool ShowEditButton 
    {
        set
        {
            AssignFlag(DataFormCommandButtonsVisibility.Edit, value);
        }
    }
      public bool ShowDeleteButton 
    {
        set
        {
            AssignFlag(DataFormCommandButtonsVisibility.Delete, value);
        }
    }
      public bool ShowNavigationButtons
      {
          set
          {
              AssignFlag(DataFormCommandButtonsVisibility.Navigation, value);
          }
      }
      public bool ShowCommitButton
      {
          set
          {
              AssignFlag(DataFormCommandButtonsVisibility.Commit, value);
          }
      }
      public bool ShowCancelButton
      {
          set
          {
              AssignFlag(DataFormCommandButtonsVisibility.Cancel, value);
          }
      }
  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 21 Jun 2011 Link to this post

    Hi Clinton,

    I have made a few attempts to reproduce the erroneous behavior with ver v2011.1.606.1040 here but with no
    I am attaching the application I have tried with . In case you can modify it in order to expose the issue , I will be glad to have a look at it again .

    Best wishes,
    Pavel Pavlov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  6. majid malik
    majid malik avatar
    2 posts
    Member since:
    Jul 2012

    Posted 23 Jul 2012 Link to this post

    instead of show/hide I want to disable/enable the Command Buttons on the RadDataForm .
    Can this be done?

    thanks in advance.
  7. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 24 Jul 2012 Link to this post

    Hello,

    These buttons are assigned with commands, which CanExecute state affects buttons' IsEnabled state. The only way to override this logic is to modify RadDataForm's template and implement your custom editing mechanism. However, I would not advise you to do this as it might interfere with another internal logic of RadDataForm.

    Regards,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. majid malik
    majid malik avatar
    2 posts
    Member since:
    Jul 2012

    Posted 24 Jul 2012 Link to this post

     



    I have the following code.


    Telerik.Windows.Controls.Data.DataForm.FormViewModel formViewModel = new FormViewModel();
     
                formViewModel.AddNewButtonVisibility = System.Windows.Visibility.Collapsed;
                formViewModel.EditButtonVisibility = System.Windows.Visibility.Collapsed;
                formViewModel.DeleteButtonVisibility = System.Windows.Visibility.Collapsed;
                formViewModel.CommitButtonVisibility = System.Windows.Visibility.Collapsed;
                formViewModel.CancelButtonVisibility = System.Windows.Visibility.Collapsed;
     
     
               this.ProgramDataForm.DataContext = formViewModel;
      
     
    but this code is not working. All buttons are visible. Is any thing special we need to do?

     

     

     

     

     

  9. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 25 Jul 2012 Link to this post

    Hello,

    RadDataForm utilizes an internal ViewModel, which is not publicly accessible. Initializing an instance of FormViewModel won't help you by any means, as it is not associated with any RadDataForm instance. Please, use RadDataForm's CommandButtonsVisibility property.

    Greetings,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner