コード例 #1
0
        protected override void InitializeControls(GenericContainer container)
        {
            IFormFieldControl thisControl     = base.ParentDesigner.PropertyEditor.Control as IFormFieldControl;
            FormDraftControl  thisControlData = base.ParentDesigner.PropertyEditor.ControlData as FormDraftControl;

            FormDescription form = FManager.GetFormByName(thisControlData.Form.Name);

            IControlsContainer cc = GetControlsContainer(form.Id);

            List <ControlData> formControls = (List <ControlData>) typeof(PageHelper)
                                              .GetMethod("SortControls", BindingFlags.Static | BindingFlags.NonPublic)
                                              .Invoke(null, new object[] { new[] { cc }, 1 });

            formControls.RemoveAll(fc => fc.ObjectType == "Telerik.Sitefinity.Modules.Forms.Web.UI.Fields.FormSubmitButton, Telerik.Sitefinity" || fc.IsLayoutControl == true);

            if (formControls.Count > 0)
            {
                List <CriteriaOption> criteriaOptions = new List <CriteriaOption>();

                CultureInfo uiCulture = CultureInfo.GetCultureInfo(this.GetUICulture());

                foreach (var formControl in formControls)
                {
                    FieldControl fieldControl = FManager.LoadControl(formControl, uiCulture) as FieldControl;

                    CriteriaOption co = new CriteriaOption();

                    if (fieldControl is FormChoiceField)
                    {
                        co.FieldType = "ChoiceField";
                        co.FieldName = Helpers.GetFieldName(fieldControl);
                        co.Options   = ((FormChoiceField)fieldControl).Choices
                                       .Select(c => new SimpleChoiceItem()
                        {
                            Text = c.Text, Value = c.Value
                        }).ToList();

                        co.Conditions = new List <SimpleChoiceItem>()
                        {
                            new SimpleChoiceItem()
                            {
                                Text = "=", Value = "=="
                            },
                            new SimpleChoiceItem()
                            {
                                Text = "!=", Value = "!="
                            }
                        };
                    }

                    if (fieldControl is TextField)
                    {
                        co.FieldType = "TextField";
                        co.FieldName = Helpers.GetFieldName(fieldControl);

                        co.Conditions = new List <SimpleChoiceItem>()
                        {
                            new SimpleChoiceItem()
                            {
                                Text = "=", Value = "=="
                            },
                            new SimpleChoiceItem()
                            {
                                Text = "!=", Value = "!="
                            },
                            new SimpleChoiceItem()
                            {
                                Text = "<", Value = "lt"
                            },
                            new SimpleChoiceItem()
                            {
                                Text = ">", Value = "gt"
                            }
                        };
                    }

                    criteriaOptions.Add(co);
                }

                StringBuilder script = new StringBuilder();

                script.Append(@"<script>");
                script.AppendFormat(@"var currentCultureC = ""{0}"";", this.GetUICulture());
                script.AppendFormat(@"var optionFilter = ""{0}"";", Helpers.GetFieldName((FieldControl)thisControl));
                script.AppendFormat(@"var criteriaOptions = {0};", Helpers.SerializeJSON <List <CriteriaOption> >(criteriaOptions));

                string criteriaSetPropertyValue = ((IConditionalFormControl)thisControl).CriteriaSet;

                string criteriaSet = "[]";

                if (!String.IsNullOrWhiteSpace(criteriaSetPropertyValue))
                {
                    criteriaSet = criteriaSetPropertyValue;
                }

                script.AppendFormat("var criteria = {0};", criteriaSet);

                script.Append(@"</script>");

                Script.Text = script.ToString();
            }
        }
コード例 #2
0
        protected override void InitializeControls(GenericContainer container)
        {
            IFormFieldControl thisControl     = base.ParentDesigner.PropertyEditor.Control as IFormFieldControl;
            FormDraftControl  thisControlData = base.ParentDesigner.PropertyEditor.ControlData as FormDraftControl;

            FormDescription form = FManager.GetFormByName(thisControlData.Form.Name);

            IControlsContainer cc = GetControlsContainer(form.Id);

            List <ControlData> formControls = (List <ControlData>) typeof(PageHelper)
                                              .GetMethod("SortControls", BindingFlags.Static | BindingFlags.NonPublic)
                                              .Invoke(null, new object[] { new[] { cc }, 1 });

            formControls.RemoveAll(fc => fc.ObjectType == "Telerik.Sitefinity.Modules.Forms.Web.UI.Fields.FormSubmitButton, Telerik.Sitefinity" || fc.IsLayoutControl == true);

            ControlData progressiveKeyFieldControlData = formControls.Where(c => ((FormDraftControl)c).Properties.Any(p => p.Name == "IsProgressiveKeyField" && p.Value == "True")).FirstOrDefault();

            if (progressiveKeyFieldControlData != null)
            {
                FieldControl progressiveKeyFieldControl = FManager.LoadControl(progressiveKeyFieldControlData, CultureInfo.CurrentUICulture) as FieldControl;

                _progressiveKeyFieldName = Helpers.GetFieldName(progressiveKeyFieldControl);

                if (!String.IsNullOrEmpty(_progressiveKeyFieldName) && _progressiveKeyFieldName != Helpers.GetFieldName(thisControl as FieldControl))
                {
                    _disableKeyFieldSelector = true;
                }
            }

            if (!(thisControl is FormTextBox))
            {
                _disableKeyFieldSelector = true;
                _wrongTypeForKeyField    = true;
            }

            if (formControls.Count > 0)
            {
                List <CriteriaOption> progressiveCriteriaOptions = new List <CriteriaOption>();

                CultureInfo uiCulture = CultureInfo.GetCultureInfo(this.GetUICulture());

                foreach (var formControl in formControls)
                {
                    FieldControl fieldControl = FManager.LoadControl(formControl, uiCulture) as FieldControl;

                    CriteriaOption co = new CriteriaOption();

                    co.FieldName = Helpers.GetFieldName(fieldControl);

                    progressiveCriteriaOptions.Add(co);
                }

                StringBuilder script = new StringBuilder();

                script.Append(@"<script>");
                script.AppendFormat(@"var currentProgressiveCulture = ""{0}"";", this.GetUICulture());
                script.AppendFormat(@"var progressiveOptionFilter = ""{0}"";", Helpers.GetFieldName((FieldControl)thisControl));
                script.AppendFormat(@"var progressiveCriteriaOptions = {0};", Helpers.SerializeJSON <List <CriteriaOption> >(progressiveCriteriaOptions));

                string progressiveCriteriaSetPropertyValue = ((IProgressiveFormControl)thisControl).ProgressiveCriteriaSet;
                string criteriaSet = "[]";

                if (!String.IsNullOrWhiteSpace(progressiveCriteriaSetPropertyValue))
                {
                    criteriaSet = progressiveCriteriaSetPropertyValue;
                }

                script.AppendFormat("var progressiveCriteria = {0};", criteriaSet);
                script.Append(@"</script>");

                Script.Text = script.ToString();
            }
        }