Example #1
0
        public static void AddDropDownList(HtmlTable htmlTable, string resourceClassName, string itemSelectorPath,
                                           string columnName, bool isNullable, string tableSchema, string tableName, string tableColumn,
                                           string defaultValue, string displayFields, string displayViews, bool useDisplayViewsAsParent,
                                           string selectedValues, string errorCssClass, Assembly assembly)
        {
            var label = ScrudLocalizationHelper.GetResourceString(assembly, resourceClassName, columnName);

            var dropDownList = GetDropDownList(columnName + "_dropdownlist");

            HtmlAnchor itemSelectorAnchor;

            using (var table = GetTable(tableSchema, tableName, tableColumn, displayViews, useDisplayViewsAsParent))
            {
                SetDisplayFields(dropDownList, table, tableSchema, tableName, tableColumn, displayFields);
                itemSelectorAnchor = GetItemSelector(dropDownList.ClientID, table, itemSelectorPath, tableSchema,
                                                     tableName, tableColumn, displayViews, assembly, resourceClassName);
            }

            SetSelectedValue(dropDownList, tableSchema, tableName, tableColumn, defaultValue, selectedValues);

            if (isNullable)
            {
                dropDownList.Items.Insert(0, new ListItem(String.Empty, String.Empty));
                ScrudFactoryHelper.AddDropDownList(htmlTable, label, dropDownList, itemSelectorAnchor, null);
            }
            else
            {
                var required = ScrudFactoryHelper.GetRequiredFieldValidator(dropDownList, errorCssClass);
                ScrudFactoryHelper.AddDropDownList(htmlTable, label + Titles.RequiredFieldIndicator, dropDownList,
                                                   itemSelectorAnchor, required);
            }
        }
Example #2
0
        internal static void AddDropDownList(string catalog, HtmlTable htmlTable, string resourceClassName, string itemSelectorPath, string columnName, bool isNullable, string tableSchema, string tableName, string tableColumn, string defaultValue, string displayFields, string displayViews, bool useDisplayViewsAsParent, string selectedValues, string errorCssClass, bool disabled)
        {
            string label = ScrudLocalizationHelper.GetResourceString(resourceClassName, columnName);

            using (DropDownList dropDownList = GetDropDownList(columnName + "_dropdownlist"))
            {
                if (disabled)
                {
                    dropDownList.Attributes.Add("disabled", "disabled");
                }

                using (DataTable table = GetTable(catalog, tableSchema, tableName, tableColumn, displayViews, useDisplayViewsAsParent))
                {
                    SetDisplayFields(dropDownList, table, tableSchema, tableName, tableColumn, displayFields);

                    using (HtmlAnchor itemSelectorAnchor = GetItemSelector(dropDownList.ClientID, itemSelectorPath, tableSchema, tableName, tableColumn, displayViews, resourceClassName, label))
                    {
                        if (disabled)
                        {
                            itemSelectorAnchor.Attributes.Add("style", "pointer-events:none;");
                        }

                        SetSelectedValue(dropDownList, tableSchema, tableName, tableColumn, defaultValue, selectedValues);

                        if (isNullable)
                        {
                            dropDownList.Items.Insert(0, new ListItem(String.Empty, String.Empty));
                            ScrudFactoryHelper.AddDropDownList(htmlTable, label, dropDownList, itemSelectorAnchor, null);
                        }
                        else
                        {
                            RequiredFieldValidator required = ScrudFactoryHelper.GetRequiredFieldValidator(dropDownList, errorCssClass);
                            ScrudFactoryHelper.AddDropDownList(htmlTable, label + Titles.RequiredFieldIndicator, dropDownList, itemSelectorAnchor, required);
                        }
                    }
                }
            }
        }
Example #3
0
        internal static void AddDropDownList(string catalog, HtmlTable container, string resourcePrefix,
                                             string itemSelectorPath, string currentSchema, string currentTable, string columnName, string label, string description,
                                             bool isNullable, string targetSchema, string targetTable,
                                             string targetColumn, string defaultValue, string displayFields, string displayViews,
                                             bool useDisplayViewsAsParent, string selectedValues, string errorCssClass, bool disabled,
                                             bool useLocalColumnInDisplayViews)
        {
            if (string.IsNullOrWhiteSpace(label))
            {
                label = ScrudLocalizationHelper.GetResourceString(resourcePrefix, columnName);
            }

            using (DropDownList dropDownList = GetDropDownList(columnName + "_dropdownlist"))
            {
                if (!string.IsNullOrWhiteSpace(description))
                {
                    dropDownList.CssClass += " activating element";
                    dropDownList.Attributes.Add("data-content", description);
                }

                if (disabled)
                {
                    dropDownList.Attributes.Add("disabled", "disabled");
                }

                using (
                    DataTable table = GetTable(catalog, targetSchema, targetTable, targetColumn,
                                               currentSchema, currentTable, columnName, displayViews, useDisplayViewsAsParent,
                                               useLocalColumnInDisplayViews))
                {
                    SetDisplayFields(catalog, dropDownList, table, targetSchema, targetTable, targetColumn,
                                     currentSchema, currentTable, columnName, displayFields,
                                     useLocalColumnInDisplayViews);

                    using (
                        HtmlAnchor itemSelectorAnchor = GetItemSelector(catalog, dropDownList.ClientID, itemSelectorPath,
                                                                        targetSchema, targetTable, targetColumn, currentSchema,
                                                                        currentTable, columnName, displayViews, resourcePrefix, label,
                                                                        useLocalColumnInDisplayViews))
                    {
                        if (disabled)
                        {
                            itemSelectorAnchor.Attributes.Add("style", "pointer-events:none;");
                        }

                        SetSelectedValue(catalog, dropDownList, targetSchema, targetTable, targetColumn,
                                         currentSchema, currentTable, columnName, defaultValue, selectedValues,
                                         useLocalColumnInDisplayViews);

                        if (isNullable)
                        {
                            dropDownList.Items.Insert(0, new ListItem(String.Empty, String.Empty));
                            ScrudFactoryHelper.AddDropDownList(container, label, dropDownList, itemSelectorAnchor, null);
                        }
                        else
                        {
                            RequiredFieldValidator required = ScrudFactoryHelper.GetRequiredFieldValidator(
                                dropDownList, errorCssClass);
                            ScrudFactoryHelper.AddDropDownList(container, label + Labels.RequiredFieldIndicator,
                                                               dropDownList, itemSelectorAnchor, required);
                        }
                    }
                }
            }
        }