Ejemplo n.º 1
0
        public override WebPart CreateWebPart(SPWeb web, Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager webPartManager)
        {
            SPList list = GetList(web, ListUrl, ListName);

            if (list == null)
            {
                return(null);
            }

            Microsoft.SharePoint.WebPartPages.ListViewWebPart webPart = new Microsoft.SharePoint.WebPartPages.ListViewWebPart();
            webPart.ListId = list.ID;
            webPart.Title  = Title;
            webPart.WebId  = list.ParentWeb.ID;


            //webPart.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.TitleAndBorder;
            SPView view = GetView(list, ViewName);

            webPart.ViewGuid    = view.ID.ToString();
            webPart.ListViewXml = view.GetViewXml();

            webPart.ExportMode = WebPartExportMode.All;
            base.UpdateProperties(webPart);
            return(webPart);
        }
Ejemplo n.º 2
0
        protected virtual void CreateContentList()
        {
            if (base.List == null) return;

            ContentList = new Microsoft.SharePoint.WebPartPages.ListViewWebPart();
            ContentList.ID = this.ID + "ContentList";
               // ContentList.Title = this.Title;
            ContentList.ListName = List.ID.ToString("B").ToUpper();

            ContentList.ListViewXml = this.ListViewXml;

            ContentList.EnableViewState = true;

            ContentList.ChromeType = PartChromeType.None; //����ʾ����

            this.Controls.Add(ContentList);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// ����Ĭ�ϵ�ListViewWebPart
        /// </summary>
        /// <param name="createToolbar"></param>
        protected virtual void CreateContentList(bool createToolbar)
        {
            SPView view = this.CurrentView;

            if (view == null) return;

            //if (!String.IsNullOrEmpty(ToolbarTemplateName))
            //{
            //    view.ToolbarTemplateName = this.ToolbarTemplateName;
            //}

            ContentList = new Microsoft.SharePoint.WebPartPages.ListViewWebPart();
            ContentList.ID = this.ID + "ContentList";
            ContentList.Title = this.Title;
            ContentList.ListName = List.ID.ToString("B").ToUpper();

            if( !String.IsNullOrEmpty((base.WebName)))
                ContentList.WebId = base.Web.ID;

            if ( ShowViewList && createToolbar )
                ContentList.ViewGuid = view.ID.ToString("B").ToUpper();
            //��ViewGuid��ֵʱ������ʾ����ͼѡ��˵�

            _ListViewXml = new XmlDocument();
            _ListViewXml.LoadXml(view.HtmlSchemaXml);

            if (this.ShowToolbar == false || createToolbar == false)
                this.HiddenToolbar(_ListViewXml);

            if (this.RowLimit > 0)
            {
                ChangeRowLimit(_ListViewXml);
            }

            ContentList.ListViewXml = _ListViewXml.InnerXml;

            ContentList.EnableViewState = true;

            //ContentList.FrameType = Microsoft.SharePoint.WebPartPages.FrameType.None;

            ContentList.ChromeType = PartChromeType.None; //����ʾ����

            if (!String.IsNullOrEmpty(ToolbarTemplateName))
            {
                foreach (Control ctl in ContentList.Controls)
                {
                    if (ctl is ViewToolBar)
                    {
                        ViewToolBar bar = (ViewToolBar)ctl;
                        bar.TemplateName = this.ToolbarTemplateName;
                        //bar.AlternateTemplateName = this.ToolbarTemplateName;
                        break;
                    }
                }
            }

            this.Controls.Add(ContentList);

            this.ContentCreated = true;
        }