1

我无法找到使用 JSLink 自定义 SP2013 任务列表项呈现的方法,以完全改变列表项的呈现方式,但同时保留默认提供的所有开箱即用功能。

我的意思是,我想将列表元素显示为彩色框,但还要保留排序选项、“...”(打开菜单)图标等。

我怎样才能实现它?是否有任何文档可以找到所有内部字段(如 PercentComplete 等)的列表,可以覆盖哪些渲染?

任何代码片段将不胜感激!

非常感谢!

4

1 回答 1

2

看看这里

简而言之,您要做的是,在Templates覆盖上下文对象中的对象上添加一个名为Fields. 在此对象中,与列(字段)的静态名称相同的属性用于使用“视图”属性呈现值。因此,链接中的示例是:

var overrideCtx = {};
overrideCtx.Templates = {};
// Override field data
overrideCtx.Templates.Fields = {
    // PercentComplate = internal name of the % Complete
    // View = you want to change the field rendering of a view
    // <div ... = here we define what the output of the field will be.
    'PercentComplete': { 'View' : '<div style="background: #F3F3F3; display:block; height: 20px; width: 100px;"><div style="background: #0072C6; height: 100%; width: <#=ctx.CurrentItem.PercentComplete.replace(" %", "")#>%;"></div></div>' }
};
// Register the override of the field
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx

使用此方法,您将在其他字段中保留默认功能。只需确保该列在当前视图中可见。

于 2013-04-10T11:24:08.843 回答