Hi. Apologies if this has been asked before. I had a bit of a search but couldn't find anything.
I'm writing a custom datatype for one of our solutions. I have my 3 classes set up (one implementing IDataEditor, one for IDataPreValue and one for IDataType) and they're all working fine. What I'd like to know though is if there's a way to force a Save on the content node which contains the data type using the Umbraco API?
Currently I'm implementing the Save method in the following way:
public void Save() { data.Value = FetchDataFromControls(); }
However, that only fires when the Save (or Save & Publish) button is clicked on the content node. I'm doing some other processing within my data type but if the end user forgets to hit "Save" after editing the content node, Umbraco doesn't pick up the changes in my control. It would be nice if within my code I could explicitly force a save of the content node within my DataEditor so this does not occur. Is there any way I can achieve this?
Hope that makes sense. I'm still pretty new to Umbraco but hope I've explained it well enough to make sense.
Yes, you can set the value property of the data object - it will do an update on the 'cmsPropertyData' database table. It doesn't need to be used in the Save() method, it can be used anywhere in your data-type.
Forcing a save within custom datatype
Hi. Apologies if this has been asked before. I had a bit of a search but couldn't find anything.
I'm writing a custom datatype for one of our solutions. I have my 3 classes set up (one implementing IDataEditor, one for IDataPreValue and one for IDataType) and they're all working fine. What I'd like to know though is if there's a way to force a Save on the content node which contains the data type using the Umbraco API?
Currently I'm implementing the Save method in the following way:
public void Save()
{
data.Value = FetchDataFromControls();
}
However, that only fires when the Save (or Save & Publish) button is clicked on the content node. I'm doing some other processing within my data type but if the end user forgets to hit "Save" after editing the content node, Umbraco doesn't pick up the changes in my control. It would be nice if within my code I could explicitly force a save of the content node within my DataEditor so this does not occur. Is there any way I can achieve this?
Hope that makes sense. I'm still pretty new to Umbraco but hope I've explained it well enough to make sense.
Cheers
Jon
Hi Jon,
Yes, you can set the value property of the data object - it will do an update on the 'cmsPropertyData' database table. It doesn't need to be used in the Save() method, it can be used anywhere in your data-type.
Cheers, Lee.
Awesome - I didn't think that would work but it does perfectly! Thanks Lee!
Hi guys,
Is there some method of doing this with a Usercontrol datatype? I mean forcing a save from within the datatype.
/Rune
is working on a reply...