Javascript 列上的JSLink Execute函数
是否可以对文件.Js中的列执行函数 示例:Javascript 列上的JSLink Execute函数,javascript,sharepoint,Javascript,Sharepoint,是否可以对文件.Js中的列执行函数 示例:供应商是我的列名 我想执行一个函数 var lookupSample = lookupSample || {}; lookupSample.CustomizeFieldRendering = function() { // Intialize the variables for overrides objects var overrideCtx = { Templates: { Fields: { 'Su
供应商
是我的列名
我想执行一个函数
var lookupSample = lookupSample || {};
lookupSample.CustomizeFieldRendering = function() {
// Intialize the variables for overrides objects
var overrideCtx = {
Templates: {
Fields: {
'Suppliers': {
'NewForm': lookupSample.singleLookupValue
},
}
}
};
overrideCtx.Templates.OnPostRender = PostRenderJs;
// Register the override of the field
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
}
lookupSample.singleLookupValue = function(ctx) {
var output = [];
var field = ctx.CurrentFieldSchema.Choices;
output.push('<div class="ui-widget"> <select id="combobox">');
// Check if field contains data
if (field.length > 0) {
for (i = 0; i < field.length; i++) {
output.push('<option id="');
output.push(field[i].LookupId);
output.push('">');
output.push(field[i].LookupValue);
output.push('</option>');
}
output.push('</select></div>');
}
// Push the value to the array
return output.join('');
}
function PostRenderJs (ctx){
alert('Hello World');
}
lookupSample.CustomizeFieldRendering();
所以它只会弹出Hello World一次。请参阅下面的代码片段: 如果只想为特定字段执行某些代码,可以直接为该特定字段编写代码
var options = {
Templates: {
Fields: {
'Field1_Internal_Name': {
View: /* function or string */,
EditForm: /* function or string */,
DisplayForm: /* function or string */,
NewForm: /* function or string */
},
}
},
};
在上面的代码片段中
参考资料:我编辑了我的文章。我只需要知道当columnname=column时如何执行函数
var options = {
Templates: {
Fields: {
'Field1_Internal_Name': {
View: /* function or string */,
EditForm: /* function or string */,
DisplayForm: /* function or string */,
NewForm: /* function or string */
},
}
},
};