Home › Forums › Classic DFFS › Rules with Readonly Checkboxes
- This topic has 7 replies, 3 voices, and was last updated 5 years, 8 months ago by Alexander Bautz.
-
AuthorPosts
-
-
August 27, 2015 at 17:28 #8255
Alexander,
I wrote a rule that made a checkbox field readonly. I assumed it would leave the checkbox selections visible and just disable them so they could not be checked or unchecked. But instead the whole field disappeared. Is that how it is supposed to work?
And a related question, is it possible through DFFS rules to make specific checkbox choices readonly, but leave others available, within the same column?
Thanks!
-
August 28, 2015 at 23:36 #8265
Using a readonly representation of a checkbox field makes sense, I have therefore added this to the upcoming release.
Your other request will however not be added as default functionality, but you can add this custom code to achieve it.
Add this to the “Run these functions / trigger these rules” in the rule:
readonlyCheckbox
Then add this to the Custom JS textarea in the “Field table, Custom JS and CSS” tab:
function readonlyCheckbox(){ spjs.$("#dffs_Color").find("input:checkbox").each(function(i,c){ if(spjs.$(c).next().text() === "Blue"){ spjs.$(c).prop("disabled",true); } }); }
Change “Color” to your field internal name and “Blue” to the option you want to set as readonly.
Alexander
-
March 27, 2019 at 14:21 #24485
Hello Alexander,
I found this thread because I stumbled up on the same issue. Although using a quiet new version checkboxes are still being removed instead of being disabled.
Is it still required to use the script or should it be included in the latest release?
Kind Regards,
Andreas -
March 27, 2019 at 17:37 #24490
Hi,
This was added back in 2015 – can you show me some screenshots so I can see how it looks in your form?PS: If it is in DispForm, you will have to use a custom script like this:
function showCheckboxesInDispForm(fin) { jQuery.ajax({ "url": _spPageContextInfo.webServerRelativeUrl + "/_api/web/lists/getbyid('" + _spPageContextInfo.pageListId + "')/fields/getByInternalNameOrTitle('" + fin + "')", "method": "GET", "headers": { "Accept": "application/json; odata=verbose" }, "success": function (data) { var arr = data.d.Choices.results, b = [], currentChoicesArr = getFieldValue(fin).split("; "); jQuery.each(arr, function (i, c) { var checked = jQuery.inArray(c, currentChoicesArr) > -1; b.push("<span class='ms-RadioText' title='" + c + "'><input type='checkbox'" + (checked ? " checked='checked'" : "") + " disabled><label>" + c + "</label></span>"); }); jQuery("#dffs_" + fin + " td.ms-formbody").html(b.join("<br>")); }, "error": function (data) { console.log("Error getting field choices:"); console.log(data); } }); } showCheckboxesInDispForm("ToDo"); // Call with the FieldInternalName of the field
Alexander
-
March 28, 2019 at 13:17 #24515
I wasn’t honest about the “almost latest version”. I’m using
DFFS frontend: 4.4.3.47
DFFS frontend CSS: 4.44 /
Autocomplete: 1.6.22
Cascading dropdowns: 3.7.22
jQuery: 1.12.4
Lookup: 1.1.11
Resource management: not loaded
SPJS-Utility: 1.323
vLookup: 2.2.122So as you can see the checkbox is visible in my EditForm and after setting the boolean field to be readonly the checkbox is set to display:none;
I’m sorry if I’m missing something obvious here.
Cheers Andreas
Attachments:
-
March 28, 2019 at 20:19 #24525
The problem is that the readonly checkbox icon is the same color as you have chosen as form background color. You must override the default color by adding this to your custom css:
.dffs-readonly-inner *{ color:#000000!important; }
Alexander
-
March 29, 2019 at 07:50 #24533
Thank you for your help, I feel stupid but it was very unfortunate that my customer did choose the same color for their background :O
-
March 29, 2019 at 15:47 #24535
No problem, I’m glad we figured it out.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.