我在SharePoint中有一个外部列表,其中包含一个URL列。URL列是SQL server中的一个计算字段,因此整个URL已经存在。我需要这个字段来超链接,我一直试图使用JSLink来做到这一点。那么JavaScript会是什么样的呢?
例如,如果我的田地是..。
第一个名称:‘.’‘
如何将配置文件URL字段中的URL获取到超链接?
我整个上午都在寻找解决办法,没有任何运气。我不熟悉JavaScript,所以我使用的代码是从我一直阅读的文章中拼凑而成的。我已经确定了我的JSLink地址是正确的。
~site/SiteAsset/myCode.js
我试过不同的代码变体。我的最新消息是:
(function () {
var profUrlField = {};
profUrlField.Templates = {};
profUrlField.Templates.Fields = {
"Profile_X0020_URL": {
"View": function (ctx) {
var urlField = ctx.CurrentItem[ctx.CurrentFieldSchema["Profile_X0020_URL"]];
return "<a href='" + urlField + "'>" + urlField + "</a>";
}
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(profileUrlField);
})();在将我的JSLink应用到我的web部件后,我重新加载页面,没有发生任何事情。没有错误但没有链接。
我也不知道如何引用这个专栏。在Server中,它是PROFILE_URL,但在SharePoint列表头中,它是Profile URL。
发布于 2019-08-27 01:52:16
按照下面的步骤修改代码,以检查它是否有效。
(function () {
var profUrlField = {};
profUrlField.Templates = {};
profUrlField.Templates.Fields = {
"PROFILE_URL": {
"View": function (ctx) {
var urlField = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
return "<a href='" + urlField + "'>" + urlField + "</a>";
}
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(profileUrlField);
})();https://stackoverflow.com/questions/57660940
复制相似问题