This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
function verySimpleView(ctx, field) { | |
var wrapper = 'This field is fully controlled by jslink<hr><span>{0}</span>'; | |
var value = ctx.CurrentItem[ctx.CurrentFieldSchema.Name] || ""; | |
return String.format(wrapper, value); | |
} | |
function verySimpleNewAndEdit(ctx) { | |
var wrapper = 'This field is fully controlled by jslink<br><input type="text" id="{0}" value"{1}"/>'; | |
var id = 'tolle-' + new Date().getTime(); | |
var formCtx = SPClientTemplates.Utility.GetFormContextForCurrentField(ctx); | |
formCtx.registerGetValueCallback(formCtx.fieldName, function () { | |
var input = document.getElementById(id); | |
return input.value; | |
}); | |
var value = ctx.CurrentItem[ctx.CurrentFieldSchema.Name] || ""; | |
var html = String.format(wrapper, id, value); | |
return html; | |
} | |
var overrideContext = {}; | |
overrideContext.Templates = overrideContext.Templates || {}; | |
overrideContext.Templates.Fields = { | |
'VerySimpleColumn': { | |
'View': verySimpleView, | |
'DisplayForm': verySimpleView, | |
'EditForm': verySimpleNewAndEdit, | |
'NewForm': verySimpleNewAndEdit | |
} | |
}; | |
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
function handleGridMode(ctx, field) { | |
field.AllowGridEditing = false; | |
} | |
function verySimpleView(ctx, field) { | |
var wrapper = 'This field is fully controlled by jslink<hr><span>{0}</span>'; | |
var value = ctx.CurrentItem[ctx.CurrentFieldSchema.Name] || ""; | |
if (ctx.inGridMode) { | |
handleGridMode(ctx, field); | |
if (value) { | |
//html = ['<div id="drop_zone">', html, '</div'].join(''); | |
} | |
} | |
return String.format(wrapper, value); | |
} | |
function verySimpleNewAndEdit(ctx) { | |
var wrapper = 'This field is fully controlled by jslink<br><input type="text" id="{0}" value"{1}"/>'; | |
var id = 'tolle-' + new Date().getTime(); | |
var formCtx = SPClientTemplates.Utility.GetFormContextForCurrentField(ctx); | |
formCtx.registerGetValueCallback(formCtx.fieldName, function () { | |
var input = document.getElementById(id); | |
return input.value; | |
}); | |
var value = ctx.CurrentItem[ctx.CurrentFieldSchema.Name] || ""; | |
var html = String.format(wrapper, id, value); | |
return html; | |
} | |
var overrideContext = {}; | |
overrideContext.Templates = overrideContext.Templates || {}; | |
overrideContext.Templates.Fields = { | |
'VerySimpleColumn': { | |
'View': verySimpleView, | |
'DisplayForm': verySimpleView, | |
'EditForm': verySimpleNewAndEdit, | |
'NewForm': verySimpleNewAndEdit | |
} | |
}; | |
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var createVerySimpleColumnGridEditControl = function (gridContext, cellControl) { | |
return { | |
SupportedWriteMode: SP.JsGrid.EditActorWriteType.LocalizedOnly, | |
SupportedReadMode: SP.JsGrid.EditActorReadType.LocalizedOnly, | |
BindToCell: function () { console.log("tolle BindToCell"); }, | |
OnCellMove: function () { console.log("tolle OnCellMove"); }, | |
Focus: function () { console.log("tolle Focus"); }, | |
OnBeginEdit: function () { console.log("tolle OnBeginEdit"); }, | |
OnEndEdit: function () { console.log("tolle OnEndEdit"); }, | |
Unbind: function () { console.log("tolle Unbind"); }, | |
Dispose: function () { console.log("tolle Dispose"); } | |
} | |
}; | |
function handleGridMode(ctx, field) { | |
SP.SOD.executeOrDelayUntilScriptLoaded(function () { | |
SP.GanttControl.WaitForGanttCreation(function (ganttChart) { | |
var verySimpleColumn = null; | |
var editId = "EDIT_TOLLE_VERYSIMPLEFIELD"; | |
var columns = ganttChart.get_Columns(); | |
for (var i = 0; i < columns.length; i++) { | |
if (columns[i].columnKey == "VerySimpleColumn") { | |
verySimpleColumn = columns[i]; | |
break; | |
} | |
} | |
verySimpleColumn.fnGetEditControlName = function (record, fieldKey) { | |
return editId; | |
}; | |
SP.JsGrid.PropertyType.Utils.RegisterEditControl(editId, function (gridContext, cellControl) { | |
return createVerySimpleColumnGridEditControl(gridContext, cellControl); | |
}, []); | |
}); | |
}, "spgantt.js"); | |
} | |
function verySimpleView(ctx, field) { | |
var wrapper = 'This field is fully controlled by jslink<hr><span>{0}</span>'; | |
var value = ctx.CurrentItem[ctx.CurrentFieldSchema.Name] || ""; | |
if (ctx.inGridMode) { | |
handleGridMode(ctx, field); | |
if (value) { | |
//html = ['<div id="drop_zone">', html, '</div'].join(''); | |
} | |
} | |
return String.format(wrapper, value); | |
} | |
function verySimpleNewAndEdit(ctx) { | |
var wrapper = 'This field is fully controlled by jslink<br><input type="text" id="{0}" value"{1}"/>'; | |
var id = 'tolle-' + new Date().getTime(); | |
var formCtx = SPClientTemplates.Utility.GetFormContextForCurrentField(ctx); | |
formCtx.registerGetValueCallback(formCtx.fieldName, function () { | |
var input = document.getElementById(id); | |
return input.value; | |
}); | |
var value = ctx.CurrentItem[ctx.CurrentFieldSchema.Name] || ""; | |
var html = String.format(wrapper, id, value); | |
return html; | |
} | |
var overrideContext = {}; | |
overrideContext.Templates = overrideContext.Templates || {}; | |
overrideContext.Templates.Fields = { | |
'VerySimpleColumn': { | |
'View': verySimpleView, | |
'DisplayForm': verySimpleView, | |
'EditForm': verySimpleNewAndEdit, | |
'NewForm': verySimpleNewAndEdit | |
} | |
}; | |
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext); | |
})(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var editWrapper = '<span>This field is fully controlled by jslink</span><br><input type="text" id="{0}" value"{1}"/>'; | |
var createVerySimpleColumnGridEditControl = function (gridContext, gridTextInputElement) { | |
var cellContext, inEdit, html, container, input, id; | |
id = "tolle-" + new Date().getTime(); | |
html = String.format(editWrapper, id, ""); | |
container = document.createElement("div"); | |
container.innerHTML = html; | |
input = container.getElementsByTagName("input")[0]; | |
container.style.cssText = 'visibility:hidden;position:absolute;top:0;left:0;background:#ffffff;'; | |
gridContext.parentNode.appendChild(container); | |
var bindToCell = function(ctx) { | |
cellContext = ctx; | |
//An input is put as an overlay. We have to set the width and height so that it takes the whole cell place | |
container.style.minWidth = cellContext.cellWidth + 'px'; | |
container.style.width = cellContext.cellWidth + 'px'; | |
container.style.height = cellContext.cellHeight + 'px'; | |
console.log("tolle BindToCell"); | |
}; | |
var onCellMove = function () { console.log("tolle OnCellMove"); }; | |
var focus = function(eventInfo) { | |
input.focus(); | |
console.log("tolle Focus", eventInfo); | |
}; | |
var onBeginEdit = function (eventInfo) { | |
inEdit = true; | |
var currentValue = cellContext.originalValue.localized; | |
if (currentValue) { | |
input.value = currentValue; | |
} | |
cellContext.Show(container); | |
console.log("tolle OnBeginEdit"); | |
this.Focus(eventInfo); | |
}; | |
var onEndEdit = function() { | |
cellContext.Hide(container); | |
inEdit = false; | |
var value = input.value; | |
cellContext.SetCurrentValue({ | |
localized: value | |
}); | |
console.log("tolle OnEndEdit"); | |
}; | |
var unbind = function() { console.log("tolle Unbind"); }; | |
var dispose = function () { console.log("tolle Dispose"); } | |
return { | |
SupportedWriteMode: window.SP.JsGrid.EditActorWriteType.LocalizedOnly, | |
SupportedReadMode: window.SP.JsGrid.EditActorReadType.LocalizedOnly, | |
BindToCell: bindToCell, | |
OnCellMove: onCellMove, | |
Focus: focus, | |
OnBeginEdit: onBeginEdit, | |
OnEndEdit: onEndEdit, | |
Unbind: unbind, | |
Dispose: dispose | |
} | |
}; | |
function handleGridMode(ctx, field) { | |
window.SP.SOD.executeOrDelayUntilScriptLoaded(function () { | |
window.SP.GanttControl.WaitForGanttCreation(function (ganttChart) { | |
var verySimpleColumn = null; | |
var editId = "EDIT_TOLLE_VERYSIMPLEFIELD"; | |
var columns = ganttChart.get_Columns(); | |
for (var i = 0; i < columns.length; i++) { | |
if (columns[i].columnKey == "VerySimpleColumn") { | |
verySimpleColumn = columns[i]; | |
break; | |
} | |
} | |
if (verySimpleColumn) { | |
verySimpleColumn.fnGetEditControlName = function (record, fieldKey) { | |
return editId; | |
}; | |
window.SP.JsGrid.PropertyType.Utils.RegisterEditControl(editId, function (gridContext, cellControl) { | |
return createVerySimpleColumnGridEditControl(gridContext, cellControl); | |
}, []); | |
} | |
}); | |
}, "spgantt.js"); | |
} | |
function verySimpleView(ctx, field) { | |
var wrapper = 'This field is fully controlled by jslink<hr><span>{0}</span>'; | |
var value = ctx.CurrentItem[ctx.CurrentFieldSchema.Name] || ""; | |
if (ctx.inGridMode) { | |
handleGridMode(ctx, field); | |
} | |
return String.format(wrapper, value); | |
} | |
function verySimpleNewAndEdit(ctx) { | |
var id = 'tolle-' + new Date().getTime(); | |
var formCtx = window.SPClientTemplates.Utility.GetFormContextForCurrentField(ctx); | |
formCtx.registerGetValueCallback(formCtx.fieldName, function () { | |
var input = document.getElementById(id); | |
return input.value; | |
}); | |
var value = ctx.CurrentItem[ctx.CurrentFieldSchema.Name] || ""; | |
var html = String.format(editWrapper, id, value); | |
return html; | |
} | |
var overrideContext = {}; | |
overrideContext.Templates = overrideContext.Templates || {}; | |
overrideContext.Templates.Fields = { | |
'VerySimpleColumn': { | |
'View': verySimpleView, | |
'DisplayForm': verySimpleView, | |
'EditForm': verySimpleNewAndEdit, | |
'NewForm': verySimpleNewAndEdit | |
} | |
}; | |
window.SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment