Page 1 of 1

Hide or read-only Checkmark field

Posted: 07 Aug 2018
by dejan.lamovsek
Hello,

I use your code to make the field read-only in a child in a quick edit mode. It works fine. Now I have a simmilar issue. To explain first.

I have a child which is a task list. A task list uses a field with internal name Checkmark to color the finish date to red if the current date is over the deadline. If the view does not show the field Checkmark, the dates do not color.

I want them to color red in the related items, but I also want the field Checkmark not to be visible, since I don't need it or at least it should be read-only. I don't want the users to click on it and finish the task.

The same problem is in list view and quick edit view. I tried to modify the code mentioned in the first sentence of this post but failed. Please advise.


Thanks,
Dejan

Re: Hide or read-only Checkmark field

Posted: 07 Aug 2018
by Nikita Kurguzov
Dear Dejan,
Do you just want to hide the field? You can set its LAYOUT -> Style to this:

Code: Select all

display:none;
This should do the trick. Unless, I am missing something, but then I'll need more information about the form and the code.

Re: Hide or read-only Checkmark field

Posted: 09 Aug 2018
by dejan.lamovsek
Hello,

we didn't quite understand each other. I have to hide or disable the field in the child. See the image below.
Disable Child Field.PNG
Disable Child Field.PNG (26.43 KiB) Viewed 2018 times
With the code below I can disable any field but not the Checkmark (marked in the image above):

(function () {
var overrideContext = {};
overrideContext.Templates = overrideContext.Templates || {};
overrideContext.Templates.OnPreRender = function(ctx) {
var statusField = ctx.ListSchema.Field.filter(function(f) {
return f.Name === 'Checkmark';
});
if (statusField) {
statusField[0].AllowGridEditing = false;
}
}
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext);
})();


If I just easily remove it from the child view, I loose the functionality to color the DueDate field to red ("Rok" in our language).

Please let me know if you need any other information.


Thank you in advance,
Dejan

Re: Hide or read-only Checkmark field

Posted: 09 Aug 2018
by Nikita Kurguzov
Dear Dejan,
You can use the following JavaScript to hide the desired column:

Code: Select all

setTimeout(function(){
	$('.related-items table tbody th:nth-of-type(2)').hide();
	$('.related-items table tbody tr td:nth-of-type(2)').hide();
}, 1500);
Just add related-items class to the correct Related Items control, change column number in :nth-of-type(2) to the correct one, and if necessary - increase the interval which is currently 1500 ms, allowing Related Items to load.

Re: Hide or read-only Checkmark field

Posted: 10 Aug 2018
by dejan.lamovsek
Works fine, thank you,

Dejan