Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Additional data fields being cleared with SaveTo method (Read 8390 times)
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Additional data fields being cleared with SaveTo method
Aug 7th, 2013 at 10:05am
Print Post  
Hi,
   I have created my own dataset based on the standard planner data set with additional fields. The issue i have is when the save to method is called it clears the data from the additional fields. I know why it does this but what i dont know is how to alter the SaveTo Method to include the new fields to prevent them being updated with null values.
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Additional data fields being cleared with SaveTo method
Reply #1 - Aug 7th, 2013 at 12:08pm
Print Post  
Hi,

Do you plan to use custom items to store this additional data?

Regards,
Meppy
  
Back to top
 
IP Logged
 
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: Additional data fields being cleared with SaveTo method
Reply #2 - Aug 7th, 2013 at 12:14pm
Print Post  
No, I am happy with the standard items. I only added fields to allow me to "select" records based on data in the additional fields, for use in other parts of my program...

  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Additional data fields being cleared with SaveTo method
Reply #3 - Aug 7th, 2013 at 1:10pm
Print Post  
Unfortunately this is not possible due to how data-binding currently works - when the calendar is saved to the database all existing database records are discarded and recreated anew. Therefore any extra information is lost.

A possible solution would be to use a custom item type that will store these extra fields in its custom properties. When saving and loading from the database the additional information will be saved/loaded along with the other item properties. To make this work I had to make some adjustments to the control (more specifically, I had to enable it to load custom items during data-binding, which was not previously possible). A sample illustrating how this is done can be downloaded from the link below (the updated control dlls are included in the sample):

https://mindfusion.eu/_samples/_sample_DataBinding.zip

The sample uses a custom item (MyItem) with a single property (Test), which is intended to store a previously defined field 'test' in the database. The point of interest is the SetupItemProperties method. Along with the standard item properties it adds a new mapping between the new database field and the items' custom property:

Code
Select All
this._calendar.ItemsDataPropertyMap.Add(new BoundProperty("test", "Test", PropertyType.Value)); 


Also note that the new ItemsDataPropertyMap.DestinationItemType property is set to typeof(MyItem) to instruct the data-binding engine what type of items to create when loading from the database.

However, using custom items can cause some implications, as outlined in the following topic:
http://www.mindfusion.eu/onlinehelp/planner/index.htm?Tutorial_4.htm

Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: Additional data fields being cleared with SaveTo method
Reply #4 - Aug 7th, 2013 at 1:21pm
Print Post  
Thanks Meppy!! I will look at this tomorrow (Its nearly midnight here) and let you know the outcome. Thanks Again, TRB
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Additional data fields being cleared with SaveTo method
Reply #5 - Aug 7th, 2013 at 1:53pm
Print Post  
On a second thought, before taking the long road, you can try saving the custom information through the item's Tag property. You may need to change the type of the Tag database field because it loads as string from the default type. If this works you can completely ignore my previous post and continue on with your version of the control.

Regards,
Meppy
  
Back to top
 
IP Logged
 
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: Additional data fields being cleared with SaveTo method
Reply #6 - Aug 8th, 2013 at 5:31am
Print Post  
Hi Meppy,
I did do that previously but i require more than the one additional field. I also tryed your suggestion and had trouble with the refferences in the database. (error i had previously). What i have don now and have it working with the contact table is created a second table called ContactInfo and used the Join function to retrieve the additional info where required. Was to focused on the issue and couldn't see a simple solution sitting right in front of me.  Thanks Again.
  

Regards,
TRB
Back to top
 
IP Logged
 
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: Additional data fields being cleared with SaveTo method
Reply #7 - Aug 13th, 2013 at 10:15am
Print Post  
Sorry Meppy, you say the save to method discards  the data and creates it anew. How is this done? Is there a way to add a WHERE clause to this?? For example "DELETE FROM Item WHERE Tag Like '" & value & "'".
  

Regards,
TRB
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Additional data fields being cleared with SaveTo method
Reply #8 - Aug 13th, 2013 at 11:13am
Print Post  
Unfortunately this is not possible. The deletion is entirely automatic and happens unconditionally before the new data is saved in the database. You will have to perform the save manually if you want to preserve some of the records.

Regards,
Meppy
  
Back to top
 
IP Logged
 
TRB
Junior Member
**
Offline


Meppy knows all!!

Posts: 80
Location: Australia
Joined: Jun 7th, 2013
Re: Additional data fields being cleared with SaveTo method
Reply #9 - Aug 13th, 2013 at 11:37am
Print Post  
Okay....I am unsure as to how this is done but am sure I will figure it out.

Thanks.
  

Regards,
TRB
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint