csr formatting for JSgrid

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
Alexey Babin
Posts: 23
Joined: Wed May 11, 2016
Contact:

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!

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

11 May 2016

Hi Alexey,

I think you need to wrap the code into this:

Code: Select all

ExecuteOrDelayUntilScriptLoaded(function() {
...
}, 'inplview.js');

User avatar
Alexey Babin
Posts: 23
Joined: Wed May 11, 2016
Contact:

11 May 2016

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?

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

12 May 2016

We are working on this feature. Hope it will become available soon.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests