У меня есть некоторый код JavaScript для рендеринга JSLINK в SP 2013. Он работает только тогда, когда таблица нефильтрована.когда таблица фильтруется, GenerateIIDForListItem генерирует неправильный идентификатор, приводя к пустой строке.
Что нужно изменить для отфильтрованной таблицы?
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
OnPostRender: function(ctx) {
$("table[summary='IT Project Pipeline - Master'] tr td:nth-child(" + PipelineColors_InternalNameIndex("Description", ctx).toString() + ") div").css("height", "60px");
$("table[summary='IT Project Pipeline - Master'] tr td:nth-child(" + PipelineColors_InternalNameIndex("Description", ctx).toString() + ") div").css("overflow-y", "scroll");
var risksColumn = PipelineColors_InternalNameIndex("Issue_x0020__x002f__x0020_Risks_", ctx).toString();
$("table[summary='IT Project Pipeline - Master'] tr td:nth-child(" + risksColumn + ") div").css("height", "60px");
$("table[summary='IT Project Pipeline - Master'] tr td:nth-child(" + risksColumn + ") div").css("overflow-y", "scroll");
var rows = ctx.ListData.Row;
for (var i=0;i<rows.length;i++)
{
if ( rows[i]["Current_x000a_Required_x002d_By_"] != null )
{
var requiredDate = PipelineColors_ConvertStringDate(rows[i]["Current_x000a_Required_x002d_By_"]);
var currentDate = new Date();
var rowId = GenerateIIDForListItem(ctx, rows[i]);
var row = document.getElementById(rowId);
if ( row != null )
{
if ( requiredDate < currentDate )
{
row.cells[PipelineColors_DisplayNameIndex("Target Date", ctx)].style.backgroundColor = "red";
}
else if ( requiredDate < currentDate.setDate(currentDate.getDate() + 30) )
{
row.cells[PipelineColors_DisplayNameIndex("Target Date", ctx)].style.backgroundColor = "yellow";
}
}
}
}
}
});
});