首页 > 代码库 > SharePoint 2013 扩展 TilesViewWebPart
SharePoint 2013 扩展 TilesViewWebPart
SharePoint 2013 增加了一个新的比较实用的 web part, 它就是TilesViewWebPart.
在新建一个Team site 后就可以在首页上看见它了:
它也可以新建议一个Promoted Link 列表作为数据源
但是如果要使用自定义的数据源怎么办呢?
答案是继承TilesViewWebPart类,并重写 GetTiles方法:
using System; using System.ComponentModel; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.WebPartPages; using Microsoft.SharePoint.Utilities; using System.Collections.Generic; namespace TilesView.MyTilesWebPart { [ToolboxItemAttribute(false)] public class MyTilesWebPart : TilesViewWebPart { private readonly string layoutsPath = "/" + SPUtility.ContextLayoutsFolder + "/TilesView/"; private readonly string tilesTitle = "My First Custom TilesWebPart"; public MyTilesWebPart() { BaseViewID = ((int)TilesBaseViewID.TileView).ToString(); } protected override TileData[] GetTiles() { List<TileData> myTiles = new List<TileData>(); myTiles.Add(new TileData { Title = "Google Search", Description = "Google Search is the search service provided by Google", LaunchBehavior = TileLaunchBehavior.Dialog, LinkLocation = "http://www.google.com", ID = 10, BackgroundImageLocation = layoutsPath + "google.jpg", TileOrder = 0 }); myTiles.Add(new TileData { Title = "Baidu search", Description = "Baidu search is the best Chinese Search", LaunchBehavior = TileLaunchBehavior.Dialog, LinkLocation = "http://www.baidu.com", ID = 20, BackgroundImageLocation = layoutsPath + "Baidu.jpg", TileOrder = 1 }); myTiles.Add(new TileData { Title = "Bing Search", Description = "Bing Search is a search service which provided by Microsoft", LaunchBehavior = TileLaunchBehavior.Dialog, LinkLocation = "http://www.bing.com", ID = 30, BackgroundImageLocation = layoutsPath + "bing.jpg", TileOrder = 2, }); return myTiles.ToArray(); } protected override string ViewTitle { get { return tilesTitle; } } } }
扩展的结果如下:
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。