Example #1
0
        public static string GetLocalizedDisplayValue(this ParentField field, string value)
        {
            string displayValue = field.GetDisplayValue(value);

            if (field.DoLocalize())
            {
                return(Map.Database.Localizer.Translate(displayValue));
            }
            else
            {
                return(displayValue);
            }
        }
Example #2
0
        public Json.Filter GetJsonFilter(View view, string guid)
        {
            Json.Filter jsonFilter = new Json.Filter();

            //foreach (Field field in view.VisibleFieldsForFilter)
            foreach (Field field in view.Fields.Values)
            {
                string type = (field.FieldType == FieldType.Children) ? "Children" : field.GetHtmlControlType().ToString();
                jsonFilter.Fields.Add(field.Name, new Json.Field()
                {
                    Name = field.Name, Type = type, Searchable = field.IsSearchable(), Permanent = false
                });
            }

            Durados.Web.Mvc.UI.Json.Filter pageFilter = view.GetPageFilter(guid);
            string parentFieldName = pageFilter.GetParentFiterFieldName();

            if (!string.IsNullOrEmpty(parentFieldName))
            {
                if (jsonFilter.Fields.ContainsKey(parentFieldName))
                {
                    Field  field    = view.Fields[parentFieldName];
                    string fieldVal = string.Empty;
                    foreach (string s in field.DatabaseNames.Split(','))
                    {
                        fieldVal += string.Format("{0},", ViewHelper.GetSessionState(guid + "PageFilterState")[s]);
                    }

                    jsonFilter.Fields[parentFieldName].Value = fieldVal.TrimEnd(',');
                    if (field.FieldType == FieldType.Parent)
                    {
                        ParentField parentField = (ParentField)field;
                        //if (parentField.ParentHtmlControlType == ParentHtmlControlType.Autocomplete)
                        //{
                        string pk = jsonFilter.Fields[parentFieldName].Value.ToString();
                        jsonFilter.Fields[parentFieldName].Default = parentField.GetDisplayValue(pk);
                        //}
                    }
                    else if (field.FieldType == FieldType.Column)
                    {
                    }


                    jsonFilter.Fields[parentFieldName].Permanent = true;
                }
                else
                {
                    if (view.IsDerived)
                    {
                        string derivedFieldName = view.GetDerivedParentField(parentFieldName).Name;
                        if (jsonFilter.Fields.ContainsKey(derivedFieldName))
                        {
                            jsonFilter.Fields[derivedFieldName].Value     = ViewHelper.GetSessionState(guid + "PageFilterState")[0];
                            jsonFilter.Fields[derivedFieldName].Permanent = true;
                        }
                    }
                }
            }



            return(jsonFilter);
        }