public override void Init(BXCustomField currentField) { field = currentField; if (field == null) return; BXParamsBag<object> settings = new BXParamsBag<object>(field.Settings); listValues = BXCustomFieldEnum.GetList(field.Id, field.FieldType, BXTextEncoder.EmptyTextEncoder); required = field.Mandatory; viewMode = settings.ContainsKey("ViewMode") ? ViewMode.List : ViewMode.Flags; listSize = settings.ContainsKey("ListSize") ? (int)settings["ListSize"] : 5; }
public void Save() { BXCustomFieldEnum.Delete( new BXFilter( new BXFilterItem(BXCustomFieldEnum.Fields.FieldType, BXSqlFilterOperators.Equal, field.FieldType), new BXFilterItem(BXCustomFieldEnum.Fields.FieldId, BXSqlFilterOperators.Equal, field.Id) ) ); bool firstRadio = false; BXCustomFieldEnumCollection values = new BXCustomFieldEnumCollection(); for (int i = 2; i < ListValue.Rows.Count; i++) { if (((CheckBox)ListValue.Rows[i].Cells[5].Controls[0]).Checked) continue; string xmlId = ((TextBox)ListValue.Rows[i].Cells[1].Controls[0]).Text; string value = ((TextBox)ListValue.Rows[i].Cells[2].Controls[0]).Text; string sortStr = ((TextBox)ListValue.Rows[i].Cells[3].Controls[0]).Text; int sort; if (!int.TryParse(sortStr, out sort)) sort = 100; bool isDefault = ((CheckBox)ListValue.Rows[i].Cells[4].Controls[0]).Checked; if (!field.Multiple) { if (!firstRadio && isDefault) firstRadio = true; else isDefault = false; } if (string.IsNullOrEmpty(xmlId) || string.IsNullOrEmpty(value)) continue; BXCustomFieldEnum item = new BXCustomFieldEnum(); item.Default = isDefault; item.Sort = sort; item.FieldType = field.FieldType; item.FieldId = field.Id; item.XmlId = xmlId; item.Value = value; values.Add(item); } values.Save(); while (ListValue.Rows.Count != 2) ListValue.Rows.RemoveAt(2); Quantity = 1; BindField(); }
public void Save() { OptimizeState(false); BXCustomFieldEnumCollection delete = new BXCustomFieldEnumCollection(); foreach (BXCustomFieldEnum e in Enums) foreach (EnumerationItem item in state) if (!item.IsNew && e.Id == item.Id) { if (item.Delete) e.Delete(); else { e.Value = item.Title; e.XmlId = item.XmlId; e.Sort = item.Sort; e.Default = item.IsDefault; e.Save(); } break; } state.RemoveAll(delegate(EnumerationItem item) { return !item.IsNew && item.Delete; }); foreach (EnumerationItem item in state) if (item.IsNew) { BXCustomFieldEnum e = new BXCustomFieldEnum(); e.FieldId = field.Id; e.FieldType = field.FieldType; e.Value = item.Title; e.XmlId = item.XmlId; e.Sort = item.Sort; e.Default = item.IsDefault; e.Save(); item.Id = e.Id; item.IsNew = false; } }