RadDataForm is really nice when binding to data with simple properties (int, string, bool, ...) but now I stuck while binding it to an entity type which has a collection of entities from another type. Let's assume there is a class Category with Fields ID (of type int) and Name (of type string) but also a property of type List<Product>.
I use a RadListBox with a custom DataTemplate to show the products (inside RadDataForm EditTemplate) but when I edit values of a product the RadDataForm does not recognize that changes as it only checks for edits at the bound object (which is the Category but not the related products). Is this possible with RadDataForm? How can I tell my RadDataForm (manually) that the CurrentItem has changed?
I use a RadListBox with a custom DataTemplate to show the products (inside RadDataForm EditTemplate) but when I edit values of a product the RadDataForm does not recognize that changes as it only checks for edits at the bound object (which is the Category but not the related products). Is this possible with RadDataForm? How can I tell my RadDataForm (manually) that the CurrentItem has changed?
12 Answers, 1 is accepted
0
Hi,
You seem to have quite a complex scenario. Would it be possible for you to open a support ticket and send us a sample dummy project that illustrates it, so that we can debug it and research for a possible solution?
Regards,
Ivan Ivanov
Telerik
You seem to have quite a complex scenario. Would it be possible for you to open a support ticket and send us a sample dummy project that illustrates it, so that we can debug it and research for a possible solution?
Regards,
Ivan Ivanov
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
Johannes
Top achievements
Rank 1
answered on 08 Jul 2014, 02:59 PM
I don't think that this is quite a complex scenario so maybe my post was written too complex. Please take a look at your WPF DataForm "FirstLook" demo as an example. Imagine an employee has not just a name and a phone number but also a list of courses he has visited. How would you display this courses list within RadDataForm?
What I try to achieve is displaying a list of objects with a RadListBox inside a RadDataForm with Add/Edit/Delete option for the list data. RadDataForm then should recognize about changes inside that list like it's getting noticed about changes in its DataFormDataFields.
What I try to achieve is displaying a list of objects with a RadListBox inside a RadDataForm with Add/Edit/Delete option for the list data. RadDataForm then should recognize about changes inside that list like it's getting noticed about changes in its DataFormDataFields.
0
Accepted
Hello,
Thank you for the clarifications. Basically, RadDataForm is notified only for PropertyChanged of its current item. I guess that you need to notify the DataForm of these changes in order to enable the Cancel operation, to revert changes on some of the items of the nested collection property, am I right? You can try implementing IEditableObject, on the CurrentItem type. Thus you will have the Cancel command to be always enabled and when the Cancel button gets clicked the IEditableObject.CancelEdit implementation will be invoked.
Regards,
Ivan Ivanov
Telerik
Thank you for the clarifications. Basically, RadDataForm is notified only for PropertyChanged of its current item. I guess that you need to notify the DataForm of these changes in order to enable the Cancel operation, to revert changes on some of the items of the nested collection property, am I right? You can try implementing IEditableObject, on the CurrentItem type. Thus you will have the Cancel command to be always enabled and when the Cancel button gets clicked the IEditableObject.CancelEdit implementation will be invoked.
Regards,
Ivan Ivanov
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
Johannes
Top achievements
Rank 1
answered on 14 Jul 2014, 11:07 AM
Thanks for your answer. I've now implemented IEditableObject to "track" changes on my bound item. In IEditableObject.CancelEdit I call CancelEdit for each child item that is displayed in the RadListBox so everything gets reset when the cancel button is clicked.
Personally I think this is a common scenario because in most cases entities have relations to other entites so I think you should add such an example to your RadDataForm documentation. Again thanks for your answer, it helped a lot at solving my problem.
Personally I think this is a common scenario because in most cases entities have relations to other entites so I think you should add such an example to your RadDataForm documentation. Again thanks for your answer, it helped a lot at solving my problem.
0
Hi,
I am glad to hear that you have managed to solve this problem. We will address this scenario in our documentation.
Regards,
Ivan Ivanov
Telerik
I am glad to hear that you have managed to solve this problem. We will address this scenario in our documentation.
Regards,
Ivan Ivanov
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
Jackey
Top achievements
Rank 1
answered on 31 Jan 2015, 12:50 AM
Hi guys,
Now I have exactly the same requirements. It seems that i need to start from scratch. Any documentation udpates about the scenario?
Now I have exactly the same requirements. It seems that i need to start from scratch. Any documentation udpates about the scenario?
0
Jackey
Top achievements
Rank 1
answered on 31 Jan 2015, 01:05 AM
Hi Jonannes,
Could you be kind enough to tell me how to do that? or share me a piece of codes? Thanks a lot!
Could you be kind enough to tell me how to do that? or share me a piece of codes? Thanks a lot!
0
Johannes
Top achievements
Rank 1
answered on 02 Feb 2015, 11:51 AM
Hello Jingfei,
I implemented IEditableObject like Ivan suggested and added a private list to track the related items in each ViewModel class. So when RadDataForm changes to Edit Mode every Property value gets backuped - and also the mentioned list. I've created a popup window where users can select the related items they want and when that window closes every selected item is added to the list. If user hits Cancel then just restore the old list state. If user hits Commit you can compare the lists current state with the old one and add/delete the corresponding relations.
I implemented IEditableObject like Ivan suggested and added a private list to track the related items in each ViewModel class. So when RadDataForm changes to Edit Mode every Property value gets backuped - and also the mentioned list. I've created a popup window where users can select the related items they want and when that window closes every selected item is added to the list. If user hits Cancel then just restore the old list state. If user hits Commit you can compare the lists current state with the old one and add/delete the corresponding relations.
0
Accepted
Hello guys,
Johannes, thanks a ton for sharing your experience! I am writing to add that we have a working online demo with IEditableObject. You can find it on demos > DataForm > FirstLook.
Regards,
Ivan Ivanov
Telerik
Johannes, thanks a ton for sharing your experience! I am writing to add that we have a working online demo with IEditableObject. You can find it on demos > DataForm > FirstLook.
Regards,
Ivan Ivanov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Jackey
Top achievements
Rank 1
answered on 09 Feb 2015, 05:41 AM
Hi Ivan,
Thanks for your direction. I've implemented the IEditableObject interface, however, i found the method of CancelEdit would be called twice when i clicked the 'cancel' button on RadDataForm. This requires my code of that method to be idempotence, which is also a little hard for me to do that. I want to know the reason behind the ​twice​ or something i did wrong.
Best wishes,
J
Thanks for your direction. I've implemented the IEditableObject interface, however, i found the method of CancelEdit would be called twice when i clicked the 'cancel' button on RadDataForm. This requires my code of that method to be idempotence, which is also a little hard for me to do that. I want to know the reason behind the ​twice​ or something i did wrong.
Best wishes,
J
0
Johannes
Top achievements
Rank 1
answered on 11 Feb 2015, 11:31 AM
If I remember correctly at MSDN you can find WHY this is executed more than once. However it's important to know THAT it can be executed many times and we have to deal with that. At MSDN they just use a simple bool value like this:
​
​
public
class
ExampleDataItemViewModel : IEditableObject
{
private
bool
_isInEditMode;
private
readonly
EditableData _editableData;
public
ExampleDataItemViewModel()
{
_isInEditMode =
false
;
_editableData =
new
EditableData();
}
// Properties, Events, Methods, ...
#region Implementation of IEditableObject
public
void
BeginEdit()
{
if
(_isInEditMode ==
false
)
{
_editableData.Value1 = Value1;
_editableData.Value2 = Value2;
_editableData.Value3 = Value3;
// ...
_isInEditMode =
true
;
}
}
public
void
CancelEdit()
{
if
(_isInEditMode)
{
Value1 = _editableData.Value1;
Value2 = _editableData.Value2;
Value3 = _editableData.Value3;
// ...
_isInEditMode =
false
;
}
}
public
void
EndEdit()
{
_isInEditMode =
false
;
}
#endregion
}
0
Jackey
Top achievements
Rank 1
answered on 11 Apr 2015, 08:45 AM
Thanks a lot for your help, Johannes.