コード例 #1
0
ファイル: ViewCreator.cs プロジェクト: nguyentuycuong/napas
        internal SPView Apply(SPList list)
        {
            try
            {
                view = list.Views[Name];
            }
            catch (Exception)
            {
                var viewFields = new StringCollection();
                foreach (var viewField in ViewFields)
                {
                    viewFields.Add(GetInternalFieldName(list, viewField));
                }

                var camlQuery = TransformCamlQuery(list, Query);

                view = list.Views.Add(Name, viewFields, camlQuery, RowLimit, true, MakeViewDefault);

                if (!string.IsNullOrEmpty(UserControlPath))
                {
                    var web = list.ParentWeb;
                    WebPartHelper.HideDefaultWebPartOnView(web, view);
                    var containerWebPart = WebPartHelper.GetContainerWebPart(web);
                    containerWebPart.Title           = string.Format(CultureInfo.InvariantCulture, "{0} - Custom View", Name);
                    containerWebPart.UserControlPath = UserControlPath;
                    WebPartHelper.AddWebPartToViewPage(web, view, containerWebPart);
                }
            }

            return(view);
        }
コード例 #2
0
ファイル: ViewCreator.cs プロジェクト: nguyentuycuong/napas
        internal void ReplaceViewControl(SPWeb web, SPList list)
        {
            WebPartHelper.HideDefaultWebPartOnView(web, view);
            var containerWebPart = WebPartHelper.GetContainerWebPart(web);

            containerWebPart.Title           = string.Format("{0} - Custom View", Name);
            containerWebPart.UserControlPath = UserControlPath;
            WebPartHelper.AddWebPartToViewPage(web, view, containerWebPart);
        }