Example #1
0
        private void AddTypeAheadFieldControls(SPField fld)
        {
            if (mode == SPControlMode.New || mode == SPControlMode.Edit)
            {
                // this represents a comma separated list of lookup field internal names to modify
                EnhancedLookupConfigValuesHelper valueHelper = null;
                string            unprocessedModCandidates   = string.Empty;
                GridGanttSettings gSettings = new GridGanttSettings(this.list);

                try
                {
                    string rawValue = gSettings.Lookups;
                    //string rawValue = "Region^dropdown^none^none^xxx|State^autocomplete^Region^Region^xxx|City^autocomplete^State^State^xxx";
                    valueHelper = new EnhancedLookupConfigValuesHelper(rawValue);
                }
                catch { }

                if (valueHelper == null)
                {
                    return;
                }


                bool isEnhanced = valueHelper.ContainsKey(fld.InternalName);
                bool isParent   = valueHelper.IsParentField(fld.InternalName);

                if (!isEnhanced && !isParent)
                {
                    return;
                }

                LookupConfigData lookupData = valueHelper.GetFieldData(fld.InternalName);

                if (isParent && !isEnhanced)
                {
                    SPFieldLookup lookupFld = fld as SPFieldLookup;
                    if (!lookupFld.AllowMultipleValues)
                    {
                        CascadingLookupRenderControl ctrl = new CascadingLookupRenderControl();
                        if (lookupData == null)
                        {
                            lookupData          = new LookupConfigData();
                            lookupData.IsParent = true;
                        }
                        ctrl.LookupData  = lookupData;
                        ctrl.LookupField = lookupFld;

                        string customValue =
                            "<Data>" +
                            "<Param key=\"SPFieldType\">SPFieldUser</Param>" +
                            "<Param key=\"ParentWebID\">" + lookupFld.ParentList.ParentWeb.ID.ToString() + "</Param>" +
                            "<Param key=\"LookupWebID\">" + lookupFld.LookupWebId.ToString() + "</Param>" +
                            "<Param key=\"LookupListID\">" + lookupFld.LookupList + "</Param>" +
                            "<Param key=\"LookupFieldInternalName\">" + lookupFld.LookupField + "</Param>" +
                            "<Param key=\"LookupFieldID\">" + lookupFld.Id + "</Param>" +
                            "<Param key=\"IsMultiSelect\">" + lookupFld.AllowMultipleValues.ToString() + "</Param>" +
                            "<Param key=\"ListID\">" + this.ListId.ToString() + "</Param>" +
                            "<Param key=\"ItemID\">" + this.ItemId.ToString() + "</Param>" +
                            "<Param key=\"Required\">" + lookupFld.Required + "</Param>" +
                            GenerateControlDataForLookupField(fld, lookupFld.AllowMultipleValues) +
                            "</Data>";

                        ctrl.CustomProperty = customValue;
                        FormField ff = this.GetFormFieldByField(fld);
                        if (ff != null)
                        {
                            ff.Parent.Controls.AddAfter(ff, ctrl);
                        }
                    }
                }
                else if (isParent && isEnhanced)
                {
                    if (lookupData.Type == GenericType)
                    {
                        #region INSERT EPMLIVE GENERIC PICKER CONTROL

                        picker = new GenericEntityEditor();
                        SPFieldLookup lookupFld = fld as SPFieldLookup;
                        picker.MultiSelect = lookupFld.AllowMultipleValues;

                        string customValue =
                            "<Data>" +
                            "<Param key=\"SPFieldType\"></Param>" +
                            "<Param key=\"ParentWebID\">" + lookupFld.ParentList.ParentWeb.ID.ToString() + "</Param>" +
                            "<Param key=\"LookupWebID\">" + lookupFld.LookupWebId.ToString() + "</Param>" +
                            "<Param key=\"LookupListID\">" + lookupFld.LookupList + "</Param>" +
                            "<Param key=\"LookupFieldInternalName\">" + lookupFld.LookupField + "</Param>" +
                            "<Param key=\"LookupFieldID\">" + lookupFld.Id + "</Param>" +
                            "<Param key=\"IsMultiSelect\">" + lookupFld.AllowMultipleValues.ToString() + "</Param>" +
                            "<Param key=\"ListID\">" + this.ListId.ToString() + "</Param>" +
                            "<Param key=\"ItemID\">" + this.ItemId.ToString() + "</Param>" +
                            GenerateControlDataForLookupField(fld, lookupFld.AllowMultipleValues) +
                            "<Param key=\"Field\">" + lookupData.Field + "</Param>" +
                            "<Param key=\"ControlType\">" + lookupData.Type + "</Param>" +
                            "<Param key=\"Parent\">" + lookupData.Parent + "</Param>" +
                            "<Param key=\"ParentListField\">" + lookupData.ParentListField + "</Param>" +
                            "<Param key=\"Required\">" + lookupFld.Required.ToString() + "</Param>" +
                            "</Data>";

                        SPFieldLookupValueCollection lookupValCol = null;

                        if (mode == SPControlMode.New || (this.list.BaseTemplate == SPListTemplateType.DocumentLibrary && !string.IsNullOrEmpty(Page.Request[ModeParam]) && Page.Request[ModeParam] == Upload && mode == SPControlMode.Edit))
                        {
                            lookupValCol = GetQueryStringLookupVal(fld);
                        }
                        else
                        {
                            try
                            {
                                lookupValCol = new SPFieldLookupValueCollection(this.ListItem[lookupFld.Id].ToString());
                            }
                            catch { }
                        }

                        if (lookupValCol != null && lookupValCol.Count > 0)
                        {
                            ArrayList    alItems = new ArrayList();
                            PickerEntity entity;
                            foreach (SPFieldLookupValue v in lookupValCol)
                            {
                                entity             = new PickerEntity();
                                entity.Key         = v.LookupId.ToString();
                                entity.DisplayText = v.LookupValue;
                                entity.IsResolved  = true;
                                alItems.Add(entity);
                            }
                            picker.UpdateEntities(alItems);
                        }

                        picker.CustomProperty = customValue;

                        FormField ff = this.GetFormFieldByField(fld);
                        if (ff != null)
                        {
                            ff.Parent.Controls.AddAfter(ff, picker);
                        }

                        #endregion
                    }
                    else if (lookupData.Type == ModifiedType)
                    {
                        #region INSERT MODIFIED SP CONTROL

                        SPFieldLookup lookupFld = fld as SPFieldLookup;
                        if (!lookupFld.AllowMultipleValues)
                        {
                            CascadingLookupRenderControl cclrCtrl = new CascadingLookupRenderControl();
                            cclrCtrl.LookupData  = lookupData;
                            cclrCtrl.LookupField = lookupFld;

                            string customValue =
                                "<Data>" +
                                "<Param key=\"SPFieldType\">SPFieldUser</Param>" +
                                "<Param key=\"ParentWebID\">" + lookupFld.ParentList.ParentWeb.ID.ToString() + "</Param>" +
                                "<Param key=\"LookupWebID\">" + lookupFld.LookupWebId.ToString() + "</Param>" +
                                "<Param key=\"LookupListID\">" + lookupFld.LookupList + "</Param>" +
                                "<Param key=\"LookupFieldInternalName\">" + lookupFld.LookupField + "</Param>" +
                                "<Param key=\"LookupFieldID\">" + lookupFld.Id + "</Param>" +
                                "<Param key=\"IsMultiSelect\">" + lookupFld.AllowMultipleValues.ToString() + "</Param>" +
                                "<Param key=\"ListID\">" + this.ListId.ToString() + "</Param>" +
                                "<Param key=\"ItemID\">" + this.ItemId.ToString() + "</Param>" +
                                "<Param key=\"Required\">" + lookupFld.Required + "</Param>" +
                                GenerateControlDataForLookupField(fld, lookupFld.AllowMultipleValues) +
                                "</Data>";

                            cclrCtrl.CustomProperty = customValue;

                            FormField ff = this.GetFormFieldByField(fld);
                            if (ff != null)
                            {
                                ff.Parent.Controls.AddAfter(ff, cclrCtrl);
                            }
                        }

                        #endregion
                    }
                }
                else if (!isParent && isEnhanced)
                {
                    if (lookupData.Type == GenericType)
                    {
                        #region INSERT EPMLIVE GENERIC PICKER CONTROL

                        picker = new GenericEntityEditor();
                        SPFieldLookup lookupFld = fld as SPFieldLookup;
                        picker.MultiSelect = lookupFld.AllowMultipleValues;

                        string customValue =
                            "<Data>" +
                            "<Param key=\"SPFieldType\">SPFieldUser</Param>" +
                            "<Param key=\"ParentWebID\">" + lookupFld.ParentList.ParentWeb.ID.ToString() + "</Param>" +
                            "<Param key=\"LookupWebID\">" + lookupFld.LookupWebId.ToString() + "</Param>" +
                            "<Param key=\"LookupListID\">" + lookupFld.LookupList + "</Param>" +
                            "<Param key=\"LookupFieldInternalName\">" + lookupFld.LookupField + "</Param>" +
                            "<Param key=\"LookupFieldID\">" + lookupFld.Id + "</Param>" +
                            "<Param key=\"IsMultiSelect\">" + lookupFld.AllowMultipleValues.ToString() + "</Param>" +
                            "<Param key=\"ListID\">" + this.ListId.ToString() + "</Param>" +
                            "<Param key=\"ItemID\">" + this.ItemId.ToString() + "</Param>" +
                            GenerateControlDataForLookupField(fld, lookupFld.AllowMultipleValues) +
                            "<Param key=\"Field\">" + lookupData.Field + "</Param>" +
                            "<Param key=\"ControlType\">" + lookupData.Type + "</Param>" +
                            "<Param key=\"Parent\">" + lookupData.Parent + "</Param>" +
                            "<Param key=\"ParentListField\">" + lookupData.ParentListField + "</Param>" +
                            "<Param key=\"Required\">" + lookupFld.Required.ToString() + "</Param>" +
                            "</Data>";

                        SPFieldLookupValueCollection lookupValCol = null;

                        if (mode == SPControlMode.New || (this.list.BaseTemplate == SPListTemplateType.DocumentLibrary && !string.IsNullOrEmpty(Page.Request[ModeParam]) && Page.Request[ModeParam] == Upload && mode == SPControlMode.Edit))
                        {
                            lookupValCol = GetQueryStringLookupVal(fld);
                        }
                        else
                        {
                            try
                            {
                                lookupValCol = new SPFieldLookupValueCollection(this.ListItem[lookupFld.Id].ToString());
                            }
                            catch { }
                        }

                        if (lookupValCol != null && lookupValCol.Count > 0)
                        {
                            ArrayList    alItems = new ArrayList();
                            PickerEntity entity;
                            foreach (SPFieldLookupValue v in lookupValCol)
                            {
                                entity             = new PickerEntity();
                                entity.Key         = v.LookupId.ToString();
                                entity.DisplayText = v.LookupValue;
                                entity.IsResolved  = true;
                                alItems.Add(entity);
                            }
                            picker.UpdateEntities(alItems);
                        }

                        picker.CustomProperty = customValue;

                        FormField ff = this.GetFormFieldByField(fld);
                        if (ff != null)
                        {
                            ff.Parent.Controls.AddAfter(ff, picker);
                        }


                        #endregion
                    }
                    else if (lookupData.Type == ModifiedType)
                    {
                        #region INSERT MODIFIED SP CONTROL

                        SPFieldLookup lookupFld = fld as SPFieldLookup;
                        if (!lookupFld.AllowMultipleValues)
                        {
                            CascadingLookupRenderControl cclrCtrl = new CascadingLookupRenderControl();
                            cclrCtrl.LookupData  = lookupData;
                            cclrCtrl.LookupField = lookupFld;

                            string customValue =
                                "<Data>" +
                                "<Param key=\"SPFieldType\">SPFieldUser</Param>" +
                                "<Param key=\"ParentWebID\">" + lookupFld.ParentList.ParentWeb.ID.ToString() + "</Param>" +
                                "<Param key=\"LookupWebID\">" + lookupFld.LookupWebId.ToString() + "</Param>" +
                                "<Param key=\"LookupListID\">" + lookupFld.LookupList + "</Param>" +
                                "<Param key=\"LookupFieldInternalName\">" + lookupFld.LookupField + "</Param>" +
                                "<Param key=\"LookupFieldID\">" + lookupFld.Id + "</Param>" +
                                "<Param key=\"IsMultiSelect\">" + lookupFld.AllowMultipleValues.ToString() + "</Param>" +
                                "<Param key=\"ListID\">" + this.ListId.ToString() + "</Param>" +
                                "<Param key=\"ItemID\">" + this.ItemId.ToString() + "</Param>" +
                                "<Param key=\"Required\">" + lookupFld.Required + "</Param>" +
                                GenerateControlDataForLookupField(fld, lookupFld.AllowMultipleValues) +
                                "</Data>";

                            cclrCtrl.CustomProperty = customValue;

                            FormField ff = this.GetFormFieldByField(fld);
                            if (ff != null)
                            {
                                ff.Parent.Controls.AddAfter(ff, cclrCtrl);
                            }
                        }
                        else
                        {
                            CascadingMultiLookupRenderControl cclrCtrl = new CascadingMultiLookupRenderControl();
                            cclrCtrl.LookupData  = lookupData;
                            cclrCtrl.LookupField = lookupFld;

                            string customValue =
                                "<Data>" +
                                "<Param key=\"SPFieldType\">SPFieldUser</Param>" +
                                "<Param key=\"ParentWebID\">" + lookupFld.ParentList.ParentWeb.ID.ToString() + "</Param>" +
                                "<Param key=\"LookupWebID\">" + lookupFld.LookupWebId.ToString() + "</Param>" +
                                "<Param key=\"LookupListID\">" + lookupFld.LookupList + "</Param>" +
                                "<Param key=\"LookupFieldInternalName\">" + lookupFld.LookupField + "</Param>" +
                                "<Param key=\"LookupFieldID\">" + lookupFld.Id + "</Param>" +
                                "<Param key=\"IsMultiSelect\">" + lookupFld.AllowMultipleValues.ToString() + "</Param>" +
                                "<Param key=\"ListID\">" + this.ListId.ToString() + "</Param>" +
                                "<Param key=\"ItemID\">" + this.ItemId.ToString() + "</Param>" +
                                "<Param key=\"Required\">" + lookupFld.Required + "</Param>" +
                                GenerateControlDataForLookupField(fld, lookupFld.AllowMultipleValues) +
                                "</Data>";

                            cclrCtrl.CustomProperty = customValue;

                            FormField ff = this.GetFormFieldByField(fld);
                            if (ff != null)
                            {
                                ff.Parent.Controls.AddAfter(ff, cclrCtrl);
                            }
                        }

                        #endregion
                    }
                }
            }
        }
Example #2
0
        private void AddEntityPickersToLookups()
        {
            if (mode == SPControlMode.New || mode == SPControlMode.Edit)
            {
                // this represents a comma separated list of lookup field internal names to modify
                EnhancedLookupConfigValuesHelper valueHelper = null;
                var gSettings = new GridGanttSettings(list);

                try
                {
                    var rawValue = gSettings.Lookups;
                    valueHelper = new EnhancedLookupConfigValuesHelper(rawValue);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                }

                if (valueHelper == null)
                {
                    return;
                }

                var formFields = this.GetFormFieldByType(typeof(SPFieldLookup));
                foreach (var formField in formFields)
                {
                    var isEnhanced = valueHelper.ContainsKey(formField.Field.InternalName);
                    var isParent   = valueHelper.IsParentField(formField.Field.InternalName);

                    if (!isEnhanced && !isParent)
                    {
                        continue;
                    }

                    var lookupData = valueHelper.GetFieldData(formField.Field.InternalName);

                    if (isParent && !isEnhanced)
                    {
                        InsertModifiedSPControl1(formField, lookupData);
                    }
                    else if (isParent && isEnhanced)
                    {
                        if (lookupData.Type == GenericType)
                        {
                            InsertEPMLiveGenericPickerControl(formField, lookupData, string.Empty);
                        }
                        else if (lookupData.Type == ModifiedType)
                        {
                            InsertModifiedSPControl1(formField, lookupData);
                        }
                    }
                    else if (!isParent && isEnhanced)
                    {
                        if (lookupData.Type == GenericType)
                        {
                            InsertEPMLiveGenericPickerControl(formField, lookupData, "SPFieldUser");
                        }
                        else if (lookupData.Type == ModifiedType)
                        {
                            InsertModifiedSPControl2(formField, lookupData);
                        }
                    }
                }
            }
        }