Пример #1
0
        private bool IsFieldExcluded2(SPField field, string displaySettings)
        {
            var    whereField     = displaySettings.Split(Separator.ToCharArray())[1];
            var    conditionField = string.Empty;
            string condition;
            var    groupField     = string.Empty;
            var    valueCondition = string.Empty;

            if (whereField.Equals(Me))
            {
                condition  = displaySettings.Split(Separator.ToCharArray())[2];
                groupField = displaySettings.Split(Separator.ToCharArray())[3];
            }
            else
            {
                conditionField = displaySettings.Split(Separator.ToCharArray())[2];
                condition      = displaySettings.Split(Separator.ToCharArray())[3];
                valueCondition = displaySettings.Split(Separator.ToCharArray())[4];
            }
            return(!EditableFieldDisplay.RenderField(
                       field,
                       whereField,
                       conditionField,
                       condition,
                       groupField,
                       valueCondition,
                       ListItem));
        }
        //protected override PickerEntity[] ResolveErrorBySearch(string unresolvedText)
        //{
        //    List<PickerEntity> entities = new List<PickerEntity>();

        //    using (SPWeb web = SPContext.Current.Site.OpenWeb(propBag.LookupWebID))
        //    {

        //        SPList list = web.Lists[propBag.LookupListID];
        //        SPField field = list.Fields[propBag.LookupFieldName];
        //        string valueType = field.TypeAsString;

        //        if (field.Type == SPFieldType.Calculated)
        //        {
        //            valueType = "Text";
        //        }

        //        SPQuery query = new SPQuery();
        //        query.ViewAttributes = "Scope=\"Recursive\"";
        //        query.Query =
        //            string.Format(
        //                "<Where><Contains><FieldRef ID=\"{0}\"/><Value Type=\"{1}\">{2}</Value></Contains></Where>",
        //                propBag.LookupFieldName, valueType, unresolvedText);
        //        SPListItemCollection items = list.GetItems(query);

        //        foreach (SPListItem item in items)
        //        {
        //            entities.Add(this.GetEntity(item));
        //        }
        //    }

        //    return entities.ToArray();
        //}

        private bool IsFieldEditable()
        {
            bool   isEditable       = true;
            string editableSettings = string.Empty;

            try
            {
                SPList            list      = SPContext.Current.List;
                SPField           field     = list.Fields.GetField(propBag.Field);
                GridGanttSettings gSettings = new GridGanttSettings(list);

                if (gSettings.DisplaySettings != "")
                {
                    fieldProperties = ListDisplayUtils.ConvertFromString(gSettings.DisplaySettings);
                }

                switch (mode)
                {
                case SPControlMode.Edit:
                {
                    try
                    {
                        editableSettings = fieldProperties[propBag.Field]["Editable"];
                    }
                    catch { }

                    if (!string.IsNullOrEmpty(editableSettings))
                    {
                        if (editableSettings.Split(";".ToCharArray())[0].ToLower().Equals("never"))
                        {
                            isEditable = false;
                        }
                        else if (editableSettings.Split(";".ToCharArray())[0].ToLower().Equals("where"))
                        {
                            string where = editableSettings.Split(";".ToCharArray())[1];
                            string conditionField = string.Empty;
                            string condition      = string.Empty;
                            string group          = string.Empty;
                            string valueCondition = string.Empty;
                            if (where.Equals("[Me]"))
                            {
                                condition = editableSettings.Split(";".ToCharArray())[2];
                                group     = editableSettings.Split(";".ToCharArray())[3];
                            }
                            else         //[Field]
                            {
                                conditionField = editableSettings.Split(";".ToCharArray())[2];
                                condition      = editableSettings.Split(";".ToCharArray())[3];
                                valueCondition = editableSettings.Split(";".ToCharArray())[4];
                            }

                            isEditable = EditableFieldDisplay.RenderField(field, where, conditionField, condition, group, valueCondition, SPContext.Current.ListItem);
                        }
                    }
                }
                break;
                }
            }
            catch { }
            return(isEditable);
        }