csr formatting for JSgrid
- Alexey Babin
- Posts: 23
- Joined: Wed May 11, 2016
- Contact:
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!
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi Alexey,
I think you need to wrap the code into this:
I think you need to wrap the code into this:
Code: Select all
ExecuteOrDelayUntilScriptLoaded(function() {
...
}, 'inplview.js');
- Alexey Babin
- Posts: 23
- Joined: Wed May 11, 2016
- Contact:
Thanks a lot! Now everything works as it should
By the way - which method of JSGrid I must use to commit the record on form's submit button?
By the way - which method of JSGrid I must use to commit the record on form's submit button?
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
We are working on this feature. Hope it will become available soon.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 13 guests