Beispiel #1
0
        // <summary>
        /// Try get parent field of a field
        /// </summary>
        /// <param name="viewName"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static ParentField GetParentField(this Field field)
        {
            ParentField parentField = null;

            if (field.FieldType == FieldType.Children)
            {
                ChildrenField childrenField = field as ChildrenField;
                if (childrenField != null)
                {
                    parentField = childrenField.GetFirstNonEquivalentParentField() as ParentField;
                }
            }
            else
            {
                parentField = field as ParentField;
            }

            return(parentField);
        }
Beispiel #2
0
        protected virtual string GetCheckListForFilter(ChildrenField field, string prefix, bool disabled, string selectedValue, string guid)
        {
            string        style      = GetFilterStyle(field);
            StringBuilder selectList = new StringBuilder();
            string        id         = guid + prefix + field.Name.ReplaceNonAlphaNumeric();
            bool          load       = !string.IsNullOrEmpty(selectedValue) || !string.IsNullOrEmpty(field.DefaultFilter);
            //Changed by br
            bool isGroupFilter = field.View != null && field.View.FilterType == FilterType.Group ? true : false;

            selectList.Append("<select " + style + " " + GetDisabledHtmlAttribute(disabled) + " id='" + id + "' name='" + field.Name + "' isGroupFilter='" + isGroupFilter + "' viewName='" + field.View.Name + "' role='childrenCheckListFilter' style='display:none' multiple='multiple' filter='filter' class='dropdownchecklist' onkeypress='handleEnterFilter(this, event, \"" + guid + "\")' >");
            selectList.Append("<option value=''>(All)</option>");

            if (load)
            {
                string[] selectedValues = field.GetFirstNonEquivalentParentField().SplitValues(selectedValue);

                bool empty = selectedValues.Contains(Database.EmptyString);
                if (prefix == filterPrefix)
                {
                    selectList.Append("<option value='" + Database.EmptyString + "' " + (empty ? "selected='selected'" : "").ToString() + ">" + field.View.Database.EmptyDisplay + "</option>");
                }

                IEnumerable <SelectListItem> selectListItems = field.GetSelectList(true);


                foreach (SelectListItem item in selectListItems)
                {
                    bool selected = selectedValues.Contains(item.Value);
                    selectList.Append("<option value='" + item.Value + "' " + (selected ? "selected='selected'>" : ">").ToString() + item.Text + "</option>");
                }
            }

            selectList.Append("</select>");

            if (!load)
            {
                //Changed by br
                string widthStyle   = GetFilterWidthStyle(field);
                string displayStyle = "display: " + (isGroupFilter ? "inline-block" : "block") + ";";
                string onclicked    = "";

                string onhovered = "";
                if (!disabled && string.IsNullOrEmpty(field.InsideTriggerFieldName))
                {
                    onclicked = " onclick='LoadCheckListFilter($(\"#" + id + "\"), \"" + guid + "\")'";
                    onhovered = " onmouseover='$(this).addClass(\"ui-state-hover\")' onmouseout='$(this).removeClass(\"ui-state-hover\")'";
                }
                string icon = "";

                if (Map.Database.Localizer.Direction != "RTL")
                {
                    icon = "<div style='float: left;' class='ui-icon ui-icon-triangle-1-e'></div>";
                }
                else
                {
                    icon = "<div style='float: right;' class='ui-icon ui-icon-triangle-1-w'></div>";
                }
                selectList.Append("<span d_ph='ph' class='ui-dropdownchecklist ui-dropdownchecklist-selector-wrapper ui-widget' style='cursor: default; overflow: hidden; " + displayStyle + widthStyle + "'><span tabindex='0'" + onclicked + " class='ui-dropdownchecklist-selector ui-state-default' style='overflow: hidden; white-space: nowrap; " + displayStyle + widthStyle + "'" + onhovered + ">" + icon + "<span style='display: inline-block; white-space: nowrap; overflow: hidden' class='ui-dropdownchecklist-text'></span></span></span>");
            }
            return(selectList.ToString());
        }