public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.StatisticsList, Name = ListsName.InternalName.StatisticsList, OnQuickLaunch = false, EnableAttachments = false }; helper.AddField(new SingleLineTextFieldCreator(FieldsName.StatisticsList.InternalName.UserBrowser, FieldsName.StatisticsList.DisplayName.UserBrowser)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.StatisticsList.InternalName.UserIP, FieldsName.StatisticsList.DisplayName.UserIP)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.StatisticsList.InternalName.UserUrl, FieldsName.StatisticsList.DisplayName.UserUrl)); SPList list = helper.Apply(); SPField fieldTitle = list.Fields.GetField(FieldsName.StatisticsList.InternalName.Title); if (fieldTitle!=null) { fieldTitle.Title = FieldsName.StatisticsList.DisplayName.Title; fieldTitle.Update(); } list.Update(); var defaultView = list.DefaultView; defaultView.ViewFields.DeleteAll(); defaultView.RowLimit = 100; defaultView.Query = "<OrderBy><FieldRef Name='ID' Ascending='FALSE' /></OrderBy>"; defaultView.ViewFields.Add(Constants.FieldTitleLinkToItem); defaultView.ViewFields.Add(FieldsName.StatisticsList.InternalName.UserBrowser); defaultView.ViewFields.Add(FieldsName.StatisticsList.InternalName.UserIP); defaultView.ViewFields.Add(FieldsName.StatisticsList.InternalName.UserUrl); defaultView.Update(); }
public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.ImageLibrary, Name = ListsName.InternalName.ImageLibrary, OnQuickLaunch = false, EnableAttachments = true }; helper.AddField(new SingleLineTextFieldCreator(FieldsName.ImageLibrary.InternalName.Description, FieldsName.CategoryList.DisplayName.Description)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ImageLibrary.InternalName.AlbumId, FieldsName.ImageLibrary.DisplayName.AlbumId)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ImageLibrary.InternalName.CategoryId, FieldsName.ImageLibrary.DisplayName.CategoryId)); helper.AddField(new ChoiceFieldCreator(FieldsName.ImageLibrary.InternalName.DisplayStatus, FieldsName.ImageLibrary.DisplayName.DisplayStatus) { Choices = { "Hiển thị", "Ẩn" }, EditFormat = SPChoiceFormatType.RadioButtons }); helper.AddField(new NumberFieldCreator(FieldsName.ImageLibrary.InternalName.Order, FieldsName.ImageLibrary.DisplayName.Order)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ImageLibrary.InternalName.FilePath, FieldsName.ImageLibrary.DisplayName.FilePath)); SPList list = helper.Apply(); SPField fieldTitle = list.Fields.GetField(FieldsName.ImageLibrary.InternalName.Title); if (fieldTitle!=null) { fieldTitle.Title = FieldsName.ImageLibrary.DisplayName.Title; fieldTitle.Update(); } list.Update(); var defaultView = list.DefaultView; defaultView.ViewFields.DeleteAll(); defaultView.Query = "<OrderBy><FieldRef Name='ID' Ascending='FALSE' /></OrderBy>"; defaultView.RowLimit = 100; defaultView.ViewFields.Add(Constants.EditColumn); defaultView.ViewFields.Add(Constants.FieldTitleLinkToItem); defaultView.Update(); }
public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.SignaturePerson, Name = ListsName.InternalName.SignaturePerson, OnQuickLaunch = false, EnableAttachments = true }; SPList list = helper.Apply(); SPField fieldTitle = list.Fields.GetField(FieldsName.SignaturePerson.InternalName.Title); if (fieldTitle!=null) { fieldTitle.Title = FieldsName.SignaturePerson.DisplayName.Title; fieldTitle.Update(); } list.Update(); var defaultView = list.DefaultView; defaultView.ViewFields.DeleteAll(); defaultView.RowLimit = 100; defaultView.ViewFields.Add(Constants.EditColumn); defaultView.ViewFields.Add(Constants.FieldTitleLinkToItem); defaultView.Update(); }
public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.IconLinkList, Name = ListsName.InternalName.IconLinkList, OnQuickLaunch = false, EnableAttachments = true }; helper.AddField(new SingleLineTextFieldCreator(FieldsName.IconLinkList.InternalName.Description, FieldsName.IconLinkList.DisplayName.Description)); helper.AddField(new NumberFieldCreator(FieldsName.IconLinkList.InternalName.Status, FieldsName.IconLinkList.DisplayName.Status)); helper.AddField(new NumberFieldCreator(FieldsName.IconLinkList.InternalName.Order, FieldsName.IconLinkList.DisplayName.Order)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.IconLinkList.InternalName.LinkURL, FieldsName.IconLinkList.DisplayName.LinkURL)); SPList list = helper.Apply(); SPField fieldTitle = list.Fields.GetField(FieldsName.IconLinkList.InternalName.Title); if (fieldTitle!=null) { fieldTitle.Title = FieldsName.IconLinkList.DisplayName.Title; fieldTitle.Update(); } list.Update(); var defaultView = list.DefaultView; defaultView.ViewFields.DeleteAll(); defaultView.RowLimit = 100; defaultView.ViewFields.Add(Constants.EditColumn); defaultView.ViewFields.Add(Constants.FieldTitleLinkToItem); defaultView.ViewFields.Add(FieldsName.IconLinkList.InternalName.Status); defaultView.ViewFields.Add(FieldsName.IconLinkList.InternalName.Order); defaultView.Update(); }
public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.ExternalNewsLinkList, Name = ListsName.InternalName.ExternalNewsLinkList, OnQuickLaunch = false, EnableAttachments = false }; helper.AddField(new SingleLineTextFieldCreator(FieldsName.ExternalNewsLink.InternalName.NewsGroup, FieldsName.ExternalNewsLink.DisplayName.NewsGroup)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ExternalNewsLink.InternalName.NewsGroupName, FieldsName.ExternalNewsLink.DisplayName.NewsGroupName)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ExternalNewsLink.InternalName.LinkPath, FieldsName.ExternalNewsLink.DisplayName.LinkPath) { EnforceUniqueValues = true }); var list = helper.Apply(); SPField fieldTitle = list.Fields.GetField(FieldsName.ExternalNewsLink.InternalName.Title); if (fieldTitle != null) { fieldTitle.Title = FieldsName.ExternalNewsLink.DisplayName.Title; fieldTitle.Update(); } list.Update(); //Add custom usercontrol to form Utilities.AddForms(web, list, "../../UserControls/ExternalNewsRSS.ascx"); var defaultView = list.DefaultView; defaultView.ViewFields.DeleteAll(); defaultView.Query = "<GroupBy Collapse='TRUE' GroupLimit='50'><FieldRef Name='" + FieldsName.ExternalNewsLink.InternalName.NewsGroupName + "' /></GroupBy>"; defaultView.RowLimit = 100; defaultView.ViewFields.Add(Constants.EditColumn); defaultView.ViewFields.Add(Constants.FieldTitleLinkToItem); defaultView.ViewFields.Add(FieldsName.ExternalNewsLink.InternalName.LinkPath); defaultView.Update(); }
public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.MenuList, Name = ListsName.InternalName.MenuList, OnQuickLaunch = false, EnableAttachments = true }; helper.AddField(new MultipleLinesTextFieldCreator(FieldsName.MenuList.InternalName.Description, FieldsName.MenuList.DisplayName.Description) { RichText = false, RichTextMode = SPRichTextMode.Compatible }); helper.AddField(new SingleLineTextFieldCreator(FieldsName.MenuList.InternalName.MenuID, FieldsName.MenuList.DisplayName.MenuID)); helper.AddField(new NumberFieldCreator(FieldsName.MenuList.InternalName.MenuOrder, FieldsName.MenuList.DisplayName.MenuOrder)); helper.AddField(new NumberFieldCreator(FieldsName.MenuList.InternalName.MenuLevel, FieldsName.MenuList.DisplayName.MenuLevel) { DefaultValue = "1"}); helper.AddField(new SingleLineTextFieldCreator(FieldsName.MenuList.InternalName.ParentID, FieldsName.MenuList.DisplayName.ParentID)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.MenuList.InternalName.ParentName, FieldsName.MenuList.DisplayName.ParentName)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.MenuList.InternalName.CatID, FieldsName.MenuList.DisplayName.CatID)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.MenuList.InternalName.CatName, FieldsName.MenuList.DisplayName.CatName)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.MenuList.InternalName.PageName, FieldsName.MenuList.DisplayName.PageName)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.MenuList.InternalName.MenuUrl, FieldsName.MenuList.DisplayName.MenuUrl)); var choiceField = new ChoiceFieldCreator(FieldsName.MenuList.InternalName.Status, FieldsName.MenuList.DisplayName.Status); choiceField.Choices.AddRange(new[] { "Ẩn", "Hiện" }); choiceField.DefaultValue = "Hiện"; helper.AddField(choiceField); choiceField = new ChoiceFieldCreator(FieldsName.MenuList.InternalName.MenuType, FieldsName.MenuList.DisplayName.MenuType); choiceField.Choices.AddRange(new[] { "Link tới chuyên mục", "Đường link xác định" }); choiceField.DefaultValue = "Link tới chuyên mục"; helper.AddField(choiceField); var choiceFields = new MultipleChoiceFieldCreator(FieldsName.MenuList.InternalName.MenuPosition, FieldsName.MenuList.DisplayName.MenuPosition); choiceFields.Choices.AddRange(new[] { "Top menu", "Footer menu", "Đơn vị" }); helper.AddField(choiceFields); choiceField = new ChoiceFieldCreator(FieldsName.MenuList.InternalName.OpenType, FieldsName.MenuList.DisplayName.OpenType); choiceField.Choices.AddRange(new[] { "Giữ nguyên cửa sổ hiện tại", "Mở cửa sổ mới" }); choiceField.DefaultValue = "Giữ nguyên cửa sổ hiện tại"; helper.AddField(choiceField); SPList list = helper.Apply(); SPField fieldTitle = list.Fields.GetFieldByInternalName(FieldsName.MenuList.InternalName.Title); if (fieldTitle != null) { fieldTitle.Title = FieldsName.MenuList.DisplayName.Title; fieldTitle.Update(); } list.Update(); //Add custom usercontrol to form Utilities.AddForms(web, list, "../../UserControls/MenuList.ascx"); //add view Utilities.AddStandardView(web, list, "AllMenu", "../../UserControls/MenuView.ascx", "", 100, true); }
public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.ResourceLibrary, Name = ListsName.InternalName.ResourceLibrary, OnQuickLaunch = false, EnableAttachments = true }; helper.AddField(new MultipleLinesTextFieldCreator(FieldsName.ResourceLibrary.InternalName.Description, FieldsName.ResourceLibrary.DisplayName.Description) { RichText = true, RichTextMode = SPRichTextMode.FullHtml }); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ResourceLibrary.InternalName.CategoryId, FieldsName.ResourceLibrary.DisplayName.CategoryId)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ResourceLibrary.InternalName.CategoryName, FieldsName.ResourceLibrary.DisplayName.CategoryName)); helper.AddField(new ChoiceFieldCreator(FieldsName.ResourceLibrary.InternalName.Status, FieldsName.ResourceLibrary.DisplayName.Status) { Choices = { "Ẩn", "Hiện" }, DefaultValue="Hiện" }); helper.AddField(new NumberFieldCreator(FieldsName.ResourceLibrary.InternalName.Order, FieldsName.ResourceLibrary.DisplayName.Order)); helper.AddField(new DateTimeFieldCreator(FieldsName.ResourceLibrary.InternalName.PostedDate, FieldsName.ResourceLibrary.DisplayName.PostedDate)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ResourceLibrary.InternalName.Author, FieldsName.ResourceLibrary.DisplayName.Author)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ResourceLibrary.InternalName.ImgThumb, FieldsName.ResourceLibrary.DisplayName.ImgThumb)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ResourceLibrary.InternalName.FileUrl, FieldsName.ResourceLibrary.DisplayName.FileUrl)); helper.AddField(new NumberFieldCreator(FieldsName.ResourceLibrary.InternalName.DownloadCount, FieldsName.ResourceLibrary.DisplayName.DownloadCount) { DefaultValue = "0" }); SPList list = helper.Apply(); SPField fieldTitle = list.Fields.GetField(FieldsName.ResourceLibrary.InternalName.Title); if (fieldTitle!=null) { fieldTitle.Title = FieldsName.ResourceLibrary.DisplayName.Title; fieldTitle.Update(); } list.Update(); //Add custom usercontrol to form Utilities.AddForms(web, list, "../../UserControls/ResourceLibrary.ascx"); var defaultView = list.DefaultView; defaultView.ViewFields.DeleteAll(); defaultView.RowLimit = 100; defaultView.Query = "<GroupBy Collapse='TRUE' GroupLimit='50'><FieldRef Name='" + FieldsName.ResourceLibrary.InternalName.CategoryName + "' /></GroupBy>"; defaultView.ViewFields.Add(Constants.EditColumn); defaultView.ViewFields.Add(Constants.FieldTitleLinkToItem); defaultView.Update(); }
public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.ProfilesList, Name = ListsName.InternalName.ProfilesList, OnQuickLaunch = false, EnableAttachments = true }; helper.AddField(new MultipleLinesTextFieldCreator(FieldsName.ProfilesList.InternalName.Description, FieldsName.ProfilesList.DisplayName.Description) { RichText = true, RichTextMode = SPRichTextMode.FullHtml }); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ProfilesList.InternalName.CategoryId, FieldsName.ProfilesList.DisplayName.CategoryId)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ProfilesList.InternalName.CategoryName, FieldsName.ProfilesList.DisplayName.CategoryName)); helper.AddField(new ChoiceFieldCreator(FieldsName.ProfilesList.InternalName.Status, FieldsName.ProfilesList.DisplayName.Status) { Choices = { "Ẩn", "Hiện" }, DefaultValue = "Hiện" }); helper.AddField(new NumberFieldCreator(FieldsName.ProfilesList.InternalName.Order, FieldsName.ProfilesList.DisplayName.Order)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ProfilesList.InternalName.Position, FieldsName.ProfilesList.DisplayName.Position)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ProfilesList.InternalName.Mobile, FieldsName.ProfilesList.DisplayName.Mobile)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ProfilesList.InternalName.Education, FieldsName.ProfilesList.DisplayName.Education)); helper.AddField(new DateTimeFieldCreator(FieldsName.ProfilesList.InternalName.DateOfBirth, FieldsName.ProfilesList.DisplayName.DateOfBirth) { DisplayFormat = SPDateTimeFieldFormatType.DateOnly}); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ProfilesList.InternalName.Phone, FieldsName.ProfilesList.DisplayName.Phone)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ProfilesList.InternalName.Specialized, FieldsName.ProfilesList.DisplayName.Specialized)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.ProfilesList.InternalName.Email, FieldsName.ProfilesList.DisplayName.Email)); SPList list = helper.Apply(); SPField fieldTitle = list.Fields.GetField(FieldsName.ProfilesList.InternalName.Title); if (fieldTitle!=null) { fieldTitle.Title = FieldsName.ProfilesList.DisplayName.Title; fieldTitle.Update(); } list.Update(); //Add custom usercontrol to form Utilities.AddForms(web, list, "../../UserControls/ProfilesList.ascx"); //add view Utilities.AddStandardView(web, list, "AllProfiles", "../../UserControls/ProfilesView.ascx", "", 100, true); }
public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.VideoLibrary, Name = ListsName.InternalName.VideoLibrary, OnQuickLaunch = false, EnableAttachments = true }; helper.AddField(new SingleLineTextFieldCreator(FieldsName.VideoLibrary.InternalName.Description, FieldsName.CategoryList.DisplayName.Description)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.VideoLibrary.InternalName.AlbumId, FieldsName.VideoLibrary.DisplayName.AlbumId)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.VideoLibrary.InternalName.CategoryId, FieldsName.VideoLibrary.DisplayName.CategoryId)); helper.AddField(new NumberFieldCreator(FieldsName.VideoLibrary.InternalName.Status, FieldsName.VideoLibrary.DisplayName.Status)); helper.AddField(new NumberFieldCreator(FieldsName.VideoLibrary.InternalName.Order, FieldsName.VideoLibrary.DisplayName.Order)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.VideoLibrary.InternalName.FilePath, FieldsName.VideoLibrary.DisplayName.FilePath)); SPList list = helper.Apply(); SPField fieldTitle = list.Fields.GetField(FieldsName.VideoLibrary.InternalName.Title); if (fieldTitle!=null) { fieldTitle.Title = FieldsName.VideoLibrary.DisplayName.Title; fieldTitle.Update(); } list.Update(); }
public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.AdvList, Name = ListsName.InternalName.AdvList, OnQuickLaunch = false, EnableAttachments = false }; helper.AddField(new MultipleLinesTextFieldCreator(FieldsName.AdvList.InternalName.Description, FieldsName.AdvList.DisplayName.Description) { RichText = false, RichTextMode = SPRichTextMode.Compatible }); helper.AddField(new SingleLineTextFieldCreator(FieldsName.AdvList.InternalName.AdvID, FieldsName.AdvList.DisplayName.AdvID)); var choiceField = new ChoiceFieldCreator(FieldsName.AdvList.InternalName.AdvType, FieldsName.AdvList.DisplayName.AdvType); choiceField.Choices.AddRange(new[] { "Images", "Flash", "Video" }); choiceField.DefaultValue = "Images"; choiceField.Required = true; helper.AddField(choiceField); helper.AddField(new SingleLineTextFieldCreator(FieldsName.AdvList.InternalName.AdvFile, FieldsName.AdvList.DisplayName.AdvFile)); choiceField = new ChoiceFieldCreator(FieldsName.AdvList.InternalName.AdvOpenType, FieldsName.AdvList.DisplayName.AdvOpenType); choiceField.Choices.AddRange(new[] { "Giữ nguyên cửa sổ hiện tại", "Mở cửa sổ mới" }); choiceField.DefaultValue = "Mở cửa sổ mới"; choiceField.Required = true; helper.AddField(choiceField); helper.AddField(new NumberFieldCreator(FieldsName.AdvList.InternalName.AdvClick, FieldsName.AdvList.DisplayName.AdvClick)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.AdvList.InternalName.AdvUrl, FieldsName.AdvList.DisplayName.AdvUrl) { Required = true }); helper.AddField(new NumberFieldCreator(FieldsName.AdvList.InternalName.AdvWidth, FieldsName.AdvList.DisplayName.AdvWidth) { Required = true }); helper.AddField(new NumberFieldCreator(FieldsName.AdvList.InternalName.AdvHeight, FieldsName.AdvList.DisplayName.AdvHeight) { Required = true }); helper.AddField(new NumberFieldCreator(FieldsName.AdvList.InternalName.AdvOrder, FieldsName.AdvList.DisplayName.AdvOrder) { Required = true, DefaultValue = "0" }); helper.AddField(new DateTimeFieldCreator(FieldsName.AdvList.InternalName.AdvStartDate, FieldsName.AdvList.DisplayName.AdvStartDate) { DisplayFormat = SPDateTimeFieldFormatType.DateTime, Required = true, DefaultValue = "[Today]" }); helper.AddField(new DateTimeFieldCreator(FieldsName.AdvList.InternalName.AdvEndDate, FieldsName.AdvList.DisplayName.AdvEndDate) { DisplayFormat = SPDateTimeFieldFormatType.DateTime, Required = true, DefaultValue = "[Today]" }); helper.AddField(new SingleLineTextFieldCreator(FieldsName.AdvList.InternalName.CustomerName, FieldsName.AdvList.DisplayName.CustomerName)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.AdvList.InternalName.CustomerAddress, FieldsName.AdvList.DisplayName.CustomerAddress)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.AdvList.InternalName.CustomerPhone, FieldsName.AdvList.DisplayName.CustomerPhone)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.AdvList.InternalName.CustomerMobile, FieldsName.AdvList.DisplayName.CustomerMobile)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.AdvList.InternalName.AdvCat, FieldsName.AdvList.DisplayName.AdvCat)); choiceField = new ChoiceFieldCreator(FieldsName.AdvList.InternalName.AdvDisplay, FieldsName.AdvList.DisplayName.AdvDisplay); choiceField.Choices.AddRange(new[] { "Hiển thị tất cả", "Hiển thị theo chuyên mục" }); choiceField.DefaultValue = "Hiển thị tất cả"; choiceField.Required = true; helper.AddField(choiceField); choiceField = new ChoiceFieldCreator(FieldsName.AdvList.InternalName.AdvPosition, FieldsName.AdvList.DisplayName.AdvPosition); choiceField.Choices.AddRange(new[] { "Trang chủ - bên trái - thứ nhất", "Trang chủ - bên trái - thứ 2", "Trang chủ - bên trái - thứ 3", "Trang chủ - bên trái - thứ 4", "Trang chủ - bên trái - thứ 5", "Trang chủ - bên trái - thứ 6", "Trang chủ - ở giữa", "Trang chủ - bên phải", "Trang tin - bên phải", "Trang tin chi tiết - bên phải", "Trang sơ đồ tổ chức - bên phải", "Trang thư viện file - bên phải", "Trang thư viện chi tiết - bên phải", "Trang giới thiệu - bên phải", "Trang văn bản - bên phải", "Trang thống kê - bên phải" }); choiceField.DefaultValue = "Trang chủ - bên trái - thứ nhất"; choiceField.Required = true; helper.AddField(choiceField); choiceField = new ChoiceFieldCreator(FieldsName.AdvList.InternalName.AdvStatus, FieldsName.AdvList.DisplayName.AdvStatus); choiceField.Choices.AddRange(new[] { "Ẩn", "Hiện" }); choiceField.DefaultValue = "Hiện"; choiceField.Required = true; helper.AddField(choiceField); SPList list = helper.Apply(); SPField fieldTitle = list.Fields.GetField(FieldsName.AdvList.InternalName.Title); if (fieldTitle!=null) { fieldTitle.Title = FieldsName.AdvList.DisplayName.Title; fieldTitle.Update(); } list.Update(); //Add custom usercontrol to form Utilities.AddForms(web, list, "../../UserControls/AdvList.ascx"); var defaultView = list.DefaultView; defaultView.ViewFields.DeleteAll(); defaultView.RowLimit = 100; defaultView.Query = "<GroupBy Collapse='TRUE' GroupLimit='50'><FieldRef Name='" + FieldsName.AdvList.InternalName.AdvPosition + "' /></GroupBy>"; defaultView.ViewFields.Add(Constants.EditColumn); defaultView.ViewFields.Add(Constants.FieldTitleLinkToItem); defaultView.ViewFields.Add(FieldsName.AdvList.InternalName.CustomerName); defaultView.ViewFields.Add(FieldsName.AdvList.InternalName.AdvUrl); defaultView.ViewFields.Add(FieldsName.AdvList.InternalName.AdvStartDate); defaultView.ViewFields.Add(FieldsName.AdvList.InternalName.AdvEndDate); defaultView.Update(); }
public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.NewsImagesList, Name = ListsName.InternalName.NewsImagesList, OnQuickLaunch = false, EnableAttachments = true, ListTemplateType=SPListTemplateType.DocumentLibrary }; helper.Apply(); helper = new ListHelper(web) { Title = ListsName.DisplayName.NewsContentImagesList, Name = ListsName.InternalName.NewsContentImagesList, OnQuickLaunch = false, EnableAttachments = true, ListTemplateType = SPListTemplateType.PictureLibrary }; helper.Apply(); helper = new ListHelper(web) { Title = ListsName.DisplayName.AllImagesList, Name = ListsName.InternalName.AllImagesList, OnQuickLaunch = false, EnableAttachments = true, ListTemplateType = SPListTemplateType.PictureLibrary }; helper.Apply(); helper = new ListHelper(web) { Title = ListsName.DisplayName.VideoImagesList, Name = ListsName.InternalName.VideoImagesList, OnQuickLaunch = false, EnableAttachments = true, ListTemplateType = SPListTemplateType.DocumentLibrary }; helper.Apply(); helper = new ListHelper(web) { Title = ListsName.DisplayName.AlbumImagesList, Name = ListsName.InternalName.AlbumImagesList, OnQuickLaunch = false, EnableAttachments = true, ListTemplateType = SPListTemplateType.DocumentLibrary }; helper.Apply(); helper = new ListHelper(web) { Title = ListsName.DisplayName.CategoryImagesList, Name = ListsName.InternalName.CategoryImagesList, OnQuickLaunch = false, EnableAttachments = true, ListTemplateType = SPListTemplateType.DocumentLibrary }; helper.Apply(); helper = new ListHelper(web) { Title = ListsName.DisplayName.GalleryImagesList, Name = ListsName.InternalName.GalleryImagesList, OnQuickLaunch = false, EnableAttachments = true, ListTemplateType = SPListTemplateType.DocumentLibrary }; helper.Apply(); helper = new ListHelper(web) { Title = ListsName.DisplayName.AdvFileList, Name = ListsName.InternalName.AdvFileList, OnQuickLaunch = false, EnableAttachments = true, ListTemplateType = SPListTemplateType.DocumentLibrary }; helper.Apply(); helper = new ListHelper(web) { Title = ListsName.DisplayName.WeatherList, Name = ListsName.InternalName.WeatherList, OnQuickLaunch = false, EnableAttachments = true, ListTemplateType = SPListTemplateType.DocumentLibrary }; helper.Apply(); }
public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.DocumentsList, Name = ListsName.InternalName.DocumentsList, OnQuickLaunch = false, EnableAttachments = true }; helper.AddField(new SingleLineTextFieldCreator(FieldsName.DocumentsList.InternalName.DocumentNo, FieldsName.DocumentsList.DisplayName.DocumentNo) { }); helper.AddField(new SingleLineTextFieldCreator(FieldsName.DocumentsList.InternalName.CategoryId, FieldsName.DocumentsList.DisplayName.CategoryId)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.DocumentsList.InternalName.CategoryName, FieldsName.DocumentsList.DisplayName.CategoryName)); helper.AddField(new LookupFieldCreator(FieldsName.DocumentsList.InternalName.DocumentSubject, FieldsName.DocumentsList.DisplayName.DocumentSubject) { LookupList = ListsName.InternalName.DocumentSubject, LookupField = FieldsName.DocumentSubject.InternalName.Title }); helper.AddField(new LookupFieldCreator(FieldsName.DocumentsList.InternalName.DocumentType, FieldsName.DocumentsList.DisplayName.DocumentType) { LookupList = ListsName.InternalName.DocumentType, LookupField = FieldsName.DocumentType.InternalName.Title }); helper.AddField(new LookupFieldCreator(FieldsName.DocumentsList.InternalName.PublishPlace, FieldsName.DocumentsList.DisplayName.PublishPlace) { LookupList = ListsName.InternalName.PublishPlace, LookupField = FieldsName.PublishPlace.InternalName.Title }); helper.AddField(new LookupFieldCreator(FieldsName.DocumentsList.InternalName.SignaturePerson, FieldsName.DocumentsList.DisplayName.SignaturePerson) { LookupList = ListsName.InternalName.SignaturePerson, LookupField = FieldsName.SignaturePerson.InternalName.Title }); helper.AddField(new DateTimeFieldCreator(FieldsName.DocumentsList.InternalName.EffectedDate, FieldsName.DocumentsList.DisplayName.EffectedDate) { DisplayFormat=SPDateTimeFieldFormatType.DateOnly }); helper.AddField(new DateTimeFieldCreator(FieldsName.DocumentsList.InternalName.ExpiredDate, FieldsName.DocumentsList.DisplayName.ExpiredDate) { DisplayFormat = SPDateTimeFieldFormatType.DateOnly }); helper.AddField(new SingleLineTextFieldCreator(FieldsName.DocumentsList.InternalName.FilePath, FieldsName.DocumentsList.DisplayName.FilePath)); SPList list = helper.Apply(); SPField fieldTitle = list.Fields.GetField(FieldsName.DocumentsList.InternalName.Title); if (fieldTitle != null) { fieldTitle.Title = FieldsName.DocumentsList.DisplayName.Title; fieldTitle.Update(); } list.Update(); //Add custom usercontrol to form Utilities.AddForms(web, list, "../../UserControls/DocumentsList.ascx"); var defaultView = list.DefaultView; defaultView.ViewFields.DeleteAll(); defaultView.RowLimit = 100; defaultView.Query = "<GroupBy Collapse='TRUE' GroupLimit='50'><FieldRef Name='" + FieldsName.DocumentsList.InternalName.DocumentType + "' /><FieldRef Name='" + FieldsName.DocumentsList.InternalName.DocumentSubject + "' /></GroupBy>"; defaultView.ViewFields.Add(Constants.EditColumn); defaultView.ViewFields.Add(Constants.FieldTitleLinkToItem); defaultView.ViewFields.Add(FieldsName.DocumentsList.InternalName.DocumentNo); defaultView.ViewFields.Add(FieldsName.DocumentsList.InternalName.PublishPlace); defaultView.ViewFields.Add(FieldsName.DocumentsList.InternalName.SignaturePerson); defaultView.ViewFields.Add(FieldsName.DocumentsList.InternalName.EffectedDate); defaultView.ViewFields.Add(FieldsName.DocumentsList.InternalName.ExpiredDate); defaultView.Update(); }
public static void CreateListStructure(SPWeb web) { var helper = new ListHelper(web) { Title = ListsName.DisplayName.NewsList, Name = ListsName.InternalName.NewsList, OnQuickLaunch = false, EnableAttachments = true }; helper.AddField(new SingleLineTextFieldCreator(FieldsName.NewsList.InternalName.NewsGroup, FieldsName.NewsList.DisplayName.NewsGroup)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.NewsList.InternalName.NewsGroupName, FieldsName.NewsList.DisplayName.NewsGroupName)); helper.AddField(new MultipleLinesTextFieldCreator(FieldsName.NewsList.InternalName.Description, FieldsName.NewsList.DisplayName.Description) { RichText = true, RichTextMode = SPRichTextMode.FullHtml }); helper.AddField(new MultipleLinesTextFieldCreator(FieldsName.NewsList.InternalName.Content, FieldsName.NewsList.DisplayName.Content) { RichText = true, RichTextMode = SPRichTextMode.FullHtml, NumberOfLines = 20 }); helper.AddField(new UserFieldCreator(FieldsName.NewsList.InternalName.Poster, FieldsName.NewsList.DisplayName.Poster) { SelectionMode = SPFieldUserSelectionMode.PeopleOnly, AllowMultipleValues = false } ); helper.AddField(new MultipleChoiceFieldCreator(FieldsName.NewsList.InternalName.Status, FieldsName.NewsList.DisplayName.Status) { Choices = { Constants.NewsStatus.HomeNews, Constants.NewsStatus.NewNews, Constants.NewsStatus.HotNews, Constants.NewsStatus.SlideNews, Constants.NewsStatus.ShouldKnowNews }, DefaultValue = Constants.NewsStatus.HomeNews }); helper.AddField(new DateTimeFieldCreator(FieldsName.NewsList.InternalName.PostedDate, FieldsName.NewsList.DisplayName.PostedDate) { DefaultValue = "[ToDay]", DisplayFormat = SPDateTimeFieldFormatType.DateTime } ); // Thumbnai image helper.AddField(new SingleLineTextFieldCreator(FieldsName.NewsList.InternalName.ImageThumb, FieldsName.NewsList.DisplayName.ImageThumb)); // Small thumbnai image helper.AddField(new SingleLineTextFieldCreator(FieldsName.NewsList.InternalName.ImageSmallThumb, FieldsName.NewsList.DisplayName.ImageSmallThumb)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.NewsList.InternalName.ImageHot, FieldsName.NewsList.DisplayName.ImageHot)); helper.AddField(new UrlFieldCreator(FieldsName.NewsList.InternalName.ImageDsp, FieldsName.NewsList.DisplayName.ImageDsp) { DisplayFormat = SPUrlFieldFormatType.Image }); helper.AddField(new SingleLineTextFieldCreator(FieldsName.NewsList.InternalName.NewsCount, FieldsName.NewsList.DisplayName.NewsCount)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.NewsList.InternalName.NewsUrl, FieldsName.NewsList.DisplayName.NewsUrl)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.NewsList.InternalName.RSSName, FieldsName.NewsList.DisplayName.RSSName)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.NewsList.InternalName.RSSLink, FieldsName.NewsList.DisplayName.RSSLink)); helper.AddField(new SingleLineTextFieldCreator(FieldsName.NewsList.InternalName.SourceName, FieldsName.NewsList.DisplayName.SourceName)); helper.AddField(new ChoiceFieldCreator(FieldsName.NewsList.InternalName.ShowHide, FieldsName.NewsList.DisplayName.ShowHide) { Choices = { Constants.NewsShowHide.Show, Constants.NewsShowHide.Hide }, DefaultValue = Constants.NewsShowHide.Show }); var list = helper.Apply(); SPField fieldTitle = list.Fields.GetField(FieldsName.NewsList.InternalName.Title); if (fieldTitle != null) { fieldTitle.Title = FieldsName.NewsList.DisplayName.Title; fieldTitle.Update(); } ////Add event receiver //Utilities.CreateEventReceivers(list, "VP.Sharepoint.CQ.EventReceivers.NewsEventReceiver", SPEventReceiverType.ItemAdded); //Utilities.CreateEventReceivers(list, "VP.Sharepoint.CQ.EventReceivers.NewsEventReceiver", SPEventReceiverType.ItemUpdated); //Add custom usercontrol to form Utilities.AddForms(web, list, "../../UserControls/NewsList.ascx"); //Create view var defaultView = list.DefaultView; defaultView.ViewFields.DeleteAll(); defaultView.RowLimit = 100; defaultView.Query = "<GroupBy Collapse='TRUE' GroupLimit='50'><FieldRef Name='" + FieldsName.NewsList.InternalName.NewsGroupName + "' /></GroupBy>"; defaultView.ViewFields.Add(Constants.EditColumn); defaultView.ViewFields.Add(FieldsName.NewsList.InternalName.ImageDsp); defaultView.ViewFields.Add(Constants.FieldTitleLinkToItem); defaultView.ViewFields.Add(FieldsName.NewsList.InternalName.Description); defaultView.ViewFields.Add(FieldsName.NewsList.InternalName.Status); defaultView.ViewFields.Add(FieldsName.NewsList.InternalName.Poster); defaultView.ViewFields.Add(FieldsName.NewsList.InternalName.PostedDate); defaultView.Update(); //add view Utilities.AddStandardView(web, list, "ExternalNews", "../../UserControls/ExternalNewsView.ascx", "", 100, false); }