Dynamically update a list based on prevalues from a dropdown datatype
I've built a custom datatype that creates a list of features for a group of venues (in this case, the libraries in our area), which, for the most part, is working properly.
The trouble I'm having is getting a field in the user control to dynamically update with the prevalues retrieved from another datatype. Currently the users pick the icon list, then manually save & reload the data type before the prevalues appear in the "Icon type" drop-down field...
Do I need to add a condition to pick up on a postback, and, if so, how do I do this?
The code for the "Add venue features" section is below...
public class VenueItems : umbraco.cms.businesslogic.datatype.DataEditorSettingType { private Panel p = new Panel(); private TextBox tb = new TextBox(); private DropDownList ddl = new DropDownList();
public override string Value { get { return tb.Text; } set { tb.Text = value; } }
// get ID of this data type from querystring int dataTypeId; if (Int32.TryParse(HttpContext.Current.Request["id"], out dataTypeId)) { // get all data editor settings for this data type DataEditorSettingsStorage des = new DataEditorSettingsStorage(); var settings = des.GetSettings(dataTypeId); Setting<string, string> thisSetting = settings.Find(s => s.Key == this.Prevalues[0]); if (thisSetting.Key != null) { int selectedDtId; if (Int32.TryParse(thisSetting.Value.ToString(), out selectedDtId)) { var prevalues = PreValues.GetPreValues(selectedDtId); if (prevalues.Count > 0) { for (int i = 0; i < prevalues.Count; i++) { var prevalue = (PreValue)prevalues[i]; if (!String.IsNullOrEmpty(prevalue.Value)) { ddl.Items.Add(new ListItem(prevalue.Value, prevalue.DataTypeId.ToString())); } } } else { ddl.Items.Add("Failed to find the icon list..."); } } } else { ddl.Items.Add("Failed to find the icon list..."); } }
Dynamically update a list based on prevalues from a dropdown datatype
I've built a custom datatype that creates a list of features for a group of venues (in this case, the libraries in our area), which, for the most part, is working properly.
The trouble I'm having is getting a field in the user control to dynamically update with the prevalues retrieved from another datatype. Currently the users pick the icon list, then manually save & reload the data type before the prevalues appear in the "Icon type" drop-down field...
Do I need to add a condition to pick up on a postback, and, if so, how do I do this?
The code for the "Add venue features" section is below...
*bump*
Comment author was deleted
Maybe the findcontrol method could be usefull here http://msdn.microsoft.com/en-us/library/31hxzsdw.aspx
Or do it with some ajax...
Thanks again Tim! I'll have a play this afternoon & see if I can get it working.
Comment author was deleted
Not sure if this is of any use http://umbraco.miketaylor.eu/2011/02/10/creating-a-custom-data-editor-setting-type/
There's also some connection between different settings
Thanks - the original idea for our datatype came about because of that article & the example on your site - http://www.nibble.be/?p=96
is working on a reply...