(function () {
// Create object that have the context information about the field that we want to change it's output render
var formTemplate = {};
formTemplate.Templates = {};
formTemplate.Templates.View = viewTemplate;
formTemplate.Templates.Fields =
{
// Apply the new rendering for Age field on New and Edit forms
"FileUpload":
{
'NewForm' : CustomField,
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(formTemplate);
})();
// This function provides the rendering logic for the Custom Form
function viewTemplate(ctx) {
var formTable = "".concat(//"",
"
Title | ", {{TitleCtrl}} | ", Date | ", {{DateCtrl}} | ",
Category | ", {{CategoryCtrl}} | ", Active | ", {{ActiveCtrl}} | ",
File Upload | ", {{FileuploadCtrl}} | ", ||
| ', ' ' | ', ', ' ' | ', ||
| ", | ", |
//Replace the tokens with the default sharepoint controls
formTable = formTable.replace("{{TitleCtrl}}", getSPFieldRender(ctx, "Title"));
formTable = formTable.replace("{{DateCtrl}}", getSPFieldRender(ctx, "Date"));
formTable = formTable.replace("{{CategoryCtrl}}", getSPFieldRender(ctx, "Category"));
formTable = formTable.replace("{{ActiveCtrl}}", getSPFieldRender(ctx, "Active"));
formTable = formTable.replace("{{FileuploadCtrl}}", getSPFieldRender(ctx, "FileUpload"));
formTable = formTable.replace("{{FormId}}", ctx.FormUniqueId);
return formTable;
}
function CustomField(ctx)
{
return '
| '+ ''+ ' '+ ''+ ' | '+ '+ class="ms-ButtonHeightWidth">'+ ''+ ''+ ' | '+
}
//This function code set the required properties and call the OOTB (default) function that use to render Sharepoint Fields
function getSPFieldRender(ctx, fieldName)
{
var fieldContext = ctx;
//Get the filed Schema
var result = ctx.ListSchema.Field.filter(function( obj ) {
return obj.Name == fieldName;
});
//Set the field Schema & default value
fieldContext.CurrentFieldSchema = result[0];
fieldContext.CurrentFieldValue = ctx.ListData.Items[0][fieldName];
//Call OOTB field render function
return ctx.Templates.Fields[fieldName](fieldContext);
}

Manikandan MurugesanPosted Jun 23, 2017, 8:42 PM