-1
是否可以在file.Js的列上执行函数?例如:Suppliers
是我的专栏名称。JSLink在列上执行函数
我想执行一个功能
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();
此代码做我想做什么,但它开3(因为我有3列在我的名单,如果我有4列,即弹出4次,等)警报与相同的消息。
而且我只想弹出此消息1次(根据我的列Suppliers
)。
喜欢的东西
function PostRenderJs (ctx){
if(ctx.columnname=="Suppliers"){
alert('Hello World');
}
};
因此,这将弹出的Hello World只有1次。如果你想执行一段特定的域代码而已,你可以直接写代码为特定领域
:
我编辑我的职务。 我只需要知道如何执行一个函数,当columnname =列 –