未定义SPClientTemplates

我想通过上传sharepoint中JS链接中的javascript文件来自定义sharepoint中的列表。所以我写了下面的代码。代码的目的是获取列Nom_x0020_Du_x0020_Projet的值,它是我想在sharepoint中定制的列表的列的内部名称,它实际上是一个链接,后面跟着它的描述。因此,代码将该列中项目的值拆分为一个数组,该数组有两个值:地址和描述。

(function(){
      // Create object that have the context information about the field that we want to change it's output render
      var nom_projetContext = {};
      nom_projetContext.Templates = {};
      nom_projetContext.Templates.Fields = {
        //Apply the new redenring for nom du projet field on the list view
        "Nom_x0020_Du_x0020_Projet" : {"View" : nomProjetModifie}
      };
      SPClientTemplates.TemplateManager.RegisterTemplateOverrides( nomProjetModifie);
})();
var adresse;
//this function provides our purpose
function nomProjetModifie(ctx){
  var nomComplet = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];

  //slice nomComplet into to substrings
  var arrayOfSubstrings = nomComplet.split(",");
  adresse = arrayOfSubstrings[0];
  var description = arrayOfSubstrings[1];

  return "<span onclcik='redirection()'>"+description+"</span>";
}

function redirection(){
  document.location.href = adresse;
}

但是无论我做什么,我都会遇到同样的错误"SPClientTemplates没有定义“。我怎么才能修复它呢?

转载请注明出处:http://www.hhy777.com/article/20230526/1503199.html