Example #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));
        }
Example #2
0
        protected override void CreateChildControls()
        {
            if (isFeatureActivated)
            {
                try
                {
                    for (int i = 0; i < Fields.Count; i++)
                    {
                        SPField field = Fields[i];
                        if (arrwpFields.Contains(field.InternalName) && mode == SPControlMode.Edit)
                        {
                            if ((bool)arrwpFields[field.InternalName])
                            {
                                TemplateContainer child = new TemplateContainer();
                                Controls.Add(child);

                                SetFieldName(child, field.InternalName);
                                SetControlMode(child, mode);

                                ControlTemplate.InstantiateIn(child);
                            }
                        }
                        else if (!IsFieldExcluded(field))
                        {
                            string editable = "";
                            try
                            {
                                editable = fieldProperties[field.InternalName]["Editable"];
                                editable = editable.Split(Separator.ToCharArray())[0].ToLower();
                            }
                            catch { }

                            if ((editable == "never" || editable == Where || field.Type == SPFieldType.Calculated) && mode != SPControlMode.New)
                            {
                                if (editable == Where && EditableFieldDisplay.canEdit(field, fieldProperties, this.ListItem))
                                {
                                    TemplateContainer child = new TemplateContainer();
                                    Controls.Add(child);

                                    SetFieldName(child, field.InternalName);
                                    SetControlMode(child, mode);

                                    ControlTemplate.InstantiateIn(child);
                                }
                                else
                                {
                                    TemplateContainer child = new TemplateContainer();
                                    Controls.Add(child);

                                    SetFieldName(child, field.InternalName);
                                    SetControlMode(child, SPControlMode.Display);

                                    ControlTemplate.InstantiateIn(child);
                                }
                            }
                            else
                            {
                                TemplateContainer child = new TemplateContainer();
                                Controls.Add(child);

                                SetFieldName(child, field.InternalName);
                                SetControlMode(child, mode);



                                ControlTemplate.InstantiateIn(child);
                            }
                        }
                    }
                }
                catch { }
                // prepopulate lookup fields with query string values

                InsertLookupValueByQueryString();

                // Add EPMLive custom entity picker control to
                // lookup fields
                if (Fields != null)
                {
                    foreach (SPField f in Fields)
                    {
                        AddTypeAheadFieldControls(f);
                    }
                }
                //AddEntityPickersToLookups();
            }
            else
            {
                base.CreateChildControls();
            }
        }
        //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);
        }