-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 =列 –