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

RadDataForm, CommandButtonsVisibility on empty ObservableCollection

7 Answers 358 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tihomir
Top achievements
Rank 1
Tihomir asked on 02 Jun 2011, 09:19 AM

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

7 Answers, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 07 Jun 2011, 10:01 AM
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
0
Clinton
Top achievements
Rank 1
answered on 15 Jun 2011, 07:25 AM
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);
      }
  }
0
Pavel Pavlov
Telerik team
answered on 21 Jun 2011, 02:17 PM
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
0
majid malik
Top achievements
Rank 1
answered on 23 Jul 2012, 11:57 PM
instead of show/hide I want to disable/enable the Command Buttons on the RadDataForm .
Can this be done?

thanks in advance.
0
Ivan Ivanov
Telerik team
answered on 24 Jul 2012, 10:57 AM
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.

0
majid malik
Top achievements
Rank 1
answered on 24 Jul 2012, 07:27 PM

 



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?

 

 

 

 

 

0
Ivan Ivanov
Telerik team
answered on 25 Jul 2012, 06:06 AM
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.

Tags
DataForm
Asked by
Tihomir
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Clinton
Top achievements
Rank 1
majid malik
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or