jeudi 22 janvier 2015

Is it possible to refer to a field hidden in current view from JSLink attached to current view?



I have the following Javascript code attached to list's JSLink property:



(function () {

var coloringFieldContext = {};
coloringFieldContext.Templates = {};

coloringFieldContext.Templates.Fields = {
"FieldName": { "View": coloringFieldTemplate }
};

SPClientTemplates.TemplateManager.RegisterTemplateOverrides(coloringFieldContext);
})();

function coloringFieldTemplate(ctx) {

var currentFieldValue = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
var currentRefferedFieldValue = ctx.CurrentItem["RefferedField"];

if (currentRefferedFieldValue === "Test") {
return "<span style='background: red;'>" + currentFieldValue + "</span>";
}
else {
return "<span style='background: green;'>" + currentFieldValue + "</span>";
}
}


If the field RefferedField is in View, then everything works just fine but when the field is hidden in current View it doesn't work.


Is there any way to make this work without showing the RefferedField column on the View?








0 commentaires:

Enregistrer un commentaire