Hide/Unhide Property based on a different properties input
Im wondering if its possible to hide/unhide a property on a form based on the input to a different property
I.E if the select support group is X then hide the impact property from the view
I would need this to be dynamic on the form as the property is changed not based on it being saved and the form reloaded
Best Answer
-
john_doyle Cireson Support Ninja IT Monkey ✭✭✭✭Try this in the custom.js file:
app.custom.formTasks.add('Incident',null, function(formObj, viewModel){
formObj.boundReady(function () {
var facilitiesGroupId = "df3896f5-3145-0546-4d25-e485de6765af";
var hide = (viewModel.TierQueue.Id == facilitiesGroupId);
hideUrgency(hide);
viewModel.bind("change", function (e) {
if (e.field === "TierQueue") {
var hide = (viewModel.TierQueue.Id == facilitiesGroupId);
hideUrgency(hide);
}
});
function hideUrgency(state) {
if (state) {
$('.control-label[for="Urgency"]').parent().parent().hide();
}
else {
$('.control-label[for="Urgency"]').parent().parent().show();
}
}
})
});
Change the guid on line 3 to match the Id of your support group.
6
Answers
$("label[for='tierQueue']").next().find("input") and then you can bind the change event and get the new value by bind("change", function(e) { e.sender.val().Name });
Or something like that...
app.custom.formTasks.add('Incident',null, function(formObj, viewModel){
formObj.boundReady(function () {
var facilitiesGroupId = "df3896f5-3145-0546-4d25-e485de6765af";
var hide = (viewModel.TierQueue.Id == facilitiesGroupId);
hideUrgency(hide);
viewModel.bind("change", function (e) {
if (e.field === "TierQueue") {
var hide = (viewModel.TierQueue.Id == facilitiesGroupId);
hideUrgency(hide);
}
});
function hideUrgency(state) {
if (state) {
$('.control-label[for="Urgency"]').parent().parent().hide();
}
else {
$('.control-label[for="Urgency"]').parent().parent().show();
}
}
})
});
Change the guid on line 3 to match the Id of your support group.
would it be
Viewmodel.Checkboxclassname.Value == true
rather than stating the guid id of the enumeration?
Sorry I'm new to JS
If your check box control is bound to a boolean property called MyCheck, then it would be
viewModel.MyCheck
That will be true if the checkbox is ticked and false if not.
The simplest thing to do is open the form in your browser and then open Developer Tools from the browser tools menu. Click on the Console tab and enter: pageForm.viewModel
You can expand the object and view the properties and objects related to the form.
Then you need to add the "disabled" attribute on both the input element and the a element, associated with the dropdown-arror like so:
and to enable it again:
This is at least the best way I found to do it.
Without having tested it, I'm guessing yes. But it wouldn't give you the "(Required)" label, so you would have too add that too. Look at Tom Hendricks example in this thread for a more complete solution: https://community.cireson.com/discussion/comment/8619/#Comment_8619 (I haven't tested this either).
So I think I've got something working. I've posted it on this discussion as where it started (https://community.cireson.com/discussion/comment/8619/#Comment_8619. Feedback/improvements welcome!