Page 1 of 1

change display mode of form with javascript

Posted: Sat Nov 10, 2018 12:42 am
by programerboy
Hi,

Can I change display mode of dynaform with javascript?
Or change display mode of a field from edit to view with javascript?

Thanks

Re: change display mode of form with javascript

Posted: Sun Nov 11, 2018 7:32 pm
by nobody
Sorry for not having the reply you might be looking for, but the following should disable all controls in the dynaform
Code: Select all
$('[class^="pmdynaform-control"]').prop('disabled',true);
$('[class^="pmdynaform-grid"]').prop('readonly',true);
$("button").prop('disabled',true);
To change the dynaform mode from edit to view (readonly) or disabled, you would need to change the backbone object like this:
Code: Select all
getFormById("3139343265babcd5465a282094686398").model.set('mode','disabled');
Usually, this should automatically fire a trigger that fould make all the fields inherit from the the dynaform backbone object, however, for some reason, I never made it to work.

Re: change display mode of form with javascript

Posted: Mon Nov 12, 2018 12:43 am
by programerboy
Thanks for you answer, it helped me a lot.

Re: change display mode of form with javascript

Posted: Wed Mar 27, 2019 9:05 am
by michaelg4s
Hi,

Are there any suggestions on how to do this for Grid fields?

I want to make certain fields in a grid object editable when a button is clicked.

Thanks

Re: change display mode of form with javascript

Posted: Wed Mar 27, 2019 7:46 pm
by amosbatto
michaelg4s wrote: Wed Mar 27, 2019 9:05 am Are there any suggestions on how to do this for Grid fields?

I want to make certain fields in a grid object editable when a button is clicked.
I have created a programming example to explain how to this:
https://www.pmusers.com/index.php/Edita ... _is_marked

Re: change display mode of form with javascript

Posted: Sun Jun 02, 2019 9:23 am
by HeshanKaru1994
Can you make some fields in a subform to be editable and rest to be in the view mode

Re: change display mode of form with javascript

Posted: Mon Jun 03, 2019 10:55 pm
by amosbatto
HeshanKaru1994 wrote: Sun Jun 02, 2019 9:23 am Can you make some fields in a subform to be editable and rest to be in the view mode
Let's say the ID of your subform is "3139343265babcd5465a282094686398", then you can add this JavaScript to your parent Dynaform to only enable the "firstName", "lastName" and "address" fields in the subform:
Code: Select all
//disable all fields in subform:
$("#3139343265babcd5465a282094686398").find(".form-control").prop("disabled", true);

//enable some fields in subform:
$("#3139343265babcd5465a282094686398").find("#firstName").find(".form-control").prop("disabled", false);
$("#3139343265babcd5465a282094686398").find("#lastName").find(".form-control").prop("disabled", false);
$("#3139343265babcd5465a282094686398").find("#address").find(".form-control").prop("disabled", false);

Re: change display mode of form with javascript

Posted: Mon Jun 03, 2019 11:53 pm
by HeshanKaru1994
Thank you

Re: change display mode of form with javascript

Posted: Wed Jul 10, 2019 4:30 pm
by devbhanu
Hi,
My form is in view mode , Can I change the display mode of the form in to edit mode when button is clicked ?

Trying this code:
$("#Edit").find("button").click(function() {
$("#Field1").getControl().attr("disabled", false);
});
or
$("#5072616315d0a42020226f9048209781").getControl().prop("disabled", false);

Thanks for your help.

Re: change display mode of form with javascript

Posted: Wed Jul 10, 2019 11:31 pm
by amosbatto
devbhanu wrote: Wed Jul 10, 2019 4:30 pm Hi,
My form is in view mode , Can I change the display mode of the form in to edit mode when button is clicked ?
I added a programming example to show how to do this:
https://www.pmusers.com/index.php/Disab ... orm_fields

Re: change display mode of form with javascript

Posted: Thu Jul 11, 2019 2:09 am
by HeshanKaru1994
Thank you Amos