csr formatting for JSgrid
Posted: 11 May 2016
The task is to customize detailed grid with some csr code. I need to remove "+" sign in the grid and prevent sorting and modifyng columns names. In order to acheive this I use JSlink property of Related table. The code I use:
var viewId;
for (viewId in g_SPGridInitInfo){
if (g_SPGridInitInfo[viewId].jsInitObj.listId ==='{D0278F39-4ED4-4B33-A3FD-3D24686ED5F3}'){
g_SPGridInitInfo[viewId].jsInitObj.canUserAddColumn = false;
g_SPGridInitInfo[viewId].jsInitObj.showAddColumn = false;
EnsureScriptParams('inplview', 'InitGridFromView', viewId);
SP.SOD.executeFunc('spgantt.js', 'SP.GanttControl', function() {
var jsGridContainer = $get("spgridcontainer_" + g_SPGridInitInfo[viewId].jsInitObj.qualifier);
var columns = jsGridContainer.jsgrid.GetColumns();
for (var i in columns)
{
columns.isSortable = false;
columns.isAutoFilterable = false;
}
jsGridContainer.jsgrid.UpdateColumns(new SP.JsGrid.ColumnInfoCollection(columns));
jsGridContainer.jsgrid.AttachEvent(SP.JsGrid.EventType.OnEntryRecordPropertyChanged, function(args) {
});
});
}
}
I tried to attach the code via JSLink tag of view defenition or write code directly in javascript section of formdesigner, but the g_SPGridInitInfo is not defined during code execution. I think I should use something like SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {} ), but I don`t understand, what exactly should be loaded. By the way, methods of SPClientTemplates work well.
And one more task to do - I need to commit the record in JSGrid when user press save button on form. By default user should click to next row in grid to commit the record and it is not obvious.
Could you give a piece of advice - how can I acheive these goals.
Thank you!
var viewId;
for (viewId in g_SPGridInitInfo){
if (g_SPGridInitInfo[viewId].jsInitObj.listId ==='{D0278F39-4ED4-4B33-A3FD-3D24686ED5F3}'){
g_SPGridInitInfo[viewId].jsInitObj.canUserAddColumn = false;
g_SPGridInitInfo[viewId].jsInitObj.showAddColumn = false;
EnsureScriptParams('inplview', 'InitGridFromView', viewId);
SP.SOD.executeFunc('spgantt.js', 'SP.GanttControl', function() {
var jsGridContainer = $get("spgridcontainer_" + g_SPGridInitInfo[viewId].jsInitObj.qualifier);
var columns = jsGridContainer.jsgrid.GetColumns();
for (var i in columns)
{
columns.isSortable = false;
columns.isAutoFilterable = false;
}
jsGridContainer.jsgrid.UpdateColumns(new SP.JsGrid.ColumnInfoCollection(columns));
jsGridContainer.jsgrid.AttachEvent(SP.JsGrid.EventType.OnEntryRecordPropertyChanged, function(args) {
});
});
}
}
I tried to attach the code via JSLink tag of view defenition or write code directly in javascript section of formdesigner, but the g_SPGridInitInfo is not defined during code execution. I think I should use something like SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {} ), but I don`t understand, what exactly should be loaded. By the way, methods of SPClientTemplates work well.
And one more task to do - I need to commit the record in JSGrid when user press save button on form. By default user should click to next row in grid to commit the record and it is not obvious.
Could you give a piece of advice - how can I acheive these goals.
Thank you!