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

RadDataForm Add Button disabled

5 Answers 204 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Sirilak Tanepoon
Top achievements
Rank 1
Sirilak Tanepoon asked on 08 Jun 2012, 10:52 AM
Dear support,

When I click "Add", fill-in data and then "OK", the data has successfully put in the collection but "Add" button is still disabled.
I have to click "Edit" follow by "Cancel" so that the "Add" button become enabled again.
What's wrong?

Meaw

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 08 Jun 2012, 11:48 AM
Hi,

 I was not able to reproduce such a behaviour at our demos. Please try what the behaviour is with the latest binaries.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Sirilak Tanepoon
Top achievements
Rank 1
answered on 17 Jun 2012, 04:08 AM
Dear support,

Now I know what cause the problem.
The dataform was bound to a ListCollectionView of objects that implement IEditableObject and INotifyPropertyChanged.
By design, those objects raised OnPropertyChanged event on EndEdit or CancelEdit method because there were some changes in their internal properties. This made the dataform think the object has been changed again so it didn't enable navigation and Add New buttons. 

My question, can we make the dataform pay attention to only those properties bound to UI element under the dataform, or is there any other solution?

thanks,
Meaw
0
Javid
Top achievements
Rank 1
answered on 08 Oct 2012, 07:15 AM
Hi Meaw,

I have a dataform with the same behavior as you described. The add button disables after adding an item. My ItemsSource is bound to a CollectionView of objects that implements IEditable interface.
I wanted to ask you if or how you solved your problem. Any help will be appreciated.

Thanks

Javid,
0
Tomasz
Top achievements
Rank 1
answered on 22 May 2013, 11:57 AM
Hello,
 for people who can face this problem too: at the moment I have solved this by using MoveCurrentToPosition(((RadDataForm)sender).CurrentIndex); in RadDataFormCommands.CommitEdit handler. But im not sure if this is an optimal solution.

Regards,
0
declan
Top achievements
Rank 1
answered on 07 Feb 2020, 04:18 PM

Another solution it is to make use of the System.Reactive library and instead of a regular property, have a IObservable property to notifiy other objects of changes. The backing field would be a subject and at the end of the EndEdit  (and/or CancelEdit) method, the subjects OnNext method would be invoked with the backup field. An abbreviated version would look something like this

 

   public class ViewModel : INotifyPropertyChanged, IEditableObject,
    {       

        private ViewModel backup;
        private readonly ISubject<ViewModel> changesSubject = new Subject<UserViewModel>();
...
        public IObservable<ViewModel> BackupChanges => changesSubject;

...

        public void EndEdit()
        {
   
            this.backupUser.UserName = _userName;
            this.backupUser.FirstName = _firstName;
            this.backupUser.LastName = _lastName;
            this.backupUser.Role = role;
            this.backupUser.Password = _password;

            changesSubject.OnNext(backupUser);
            //this.RaisePropertyChanged(nameof(BackupChanges));
        }

    }

Tags
DataForm
Asked by
Sirilak Tanepoon
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Sirilak Tanepoon
Top achievements
Rank 1
Javid
Top achievements
Rank 1
Tomasz
Top achievements
Rank 1
declan
Top achievements
Rank 1
Share this question
or