Hide Save Form Button

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
BLOMASKY
Posts: 1473
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Hide Save Form Button

Post by BLOMASKY »

I have a form with a Save Form button. There are times I display the form with everything PROTECTED (like, after an order has shipped), so everything is read only. There is no problem protecting all of the fields, but the button is still visible and the user can click it. How can I make this button go away?

Thanks
Bruce
BenHayat
Posts: 2749
Joined: Thu Dec 23, 2010 5:48 am
Location: Fla, USA
Contact:

Re: Hide Save Form Button

Post by BenHayat »

BLOMASKY wrote:I have a form with a Save Form button. There are times I display the form with everything PROTECTED (like, after an order has shipped), so everything is read only. There is no problem protecting all of the fields, but the button is still visible and the user can click it. How can I make this button go away?

Thanks
Bruce
In your form operation section, you have two buttons by default (Save and close). You can remove the save button.
BLOMASKY
Posts: 1473
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Hide Save Form Button

Post by BLOMASKY »

I don't want to remove the button, (cause, many times the user CAN and WILL edit the data, but after the order has shipped, I don't want that button (and really don't want to duplicate the form, having 2, one for editing and one for viewing.
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: Hide Save Form Button

Post by johntalbott »

Pretty much any of this kind of stuff can be done with a script.
VocalDay Solutions - Agility - Predictability - Quality

We specialize in enabling business through the innovative use of technology.

AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Hide Save Form Button

Post by aware_support »

John is right - a script would easily remove any buttons in any forms or queries.

In this particular case you can also protect the entire object, not individual fields - if the entire object is protected the Save button should be removed.

And I think the VIEW operation, rather than Edit to bring up the form will have the same effect (not too sure about this one)
Aware IM Support Team
BLOMASKY
Posts: 1473
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Hide Save Form Button

Post by BLOMASKY »

and, perhaps, you can share the script that would remove a button? pretty please???
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Hide Save Form Button

Post by aware_support »

This "render" script should do it:

$("#" + parser.m_widgetInfo.wrapperId).find (".aw-form-buttons .k-primary.k-button").css ("display", "none");
Aware IM Support Team
BLOMASKY
Posts: 1473
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Hide Save Form Button

Post by BLOMASKY »

Thanks for the reply, but its getting a tad off topic. I only want to "Conditionally" hide the save button. So can that be done in the advanced script section of the form?

Thanks
Bruce
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Hide Save Form Button

Post by aware_support »

Yes, you can add conditions to this statement
Aware IM Support Team
BLOMASKY
Posts: 1473
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Hide Save Form Button

Post by BLOMASKY »

What I don't know is how to access an attribute in the BO in scope. (in this case, I have an attribute called "status" and it's not displayed on the form, but if status = 'Complete' then I want to remove the button. Is there a tutorial (or some help somewhere) on how to access BO.attributes in the advanced script section. (I assume its not <<BO.attrName>> like we do everywhere else!)


Bruce
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Hide Save Form Button

Post by aware_support »

First of all you MUST add this attribute to the form (doesn't matter where), but it should be hidden. To hide an attribute add the following to the script of the attribute:

markup.css ("display", "none");

Then to access it use this in the render script of the form:

var field = parser.getField ("AttributeName");

To get the current value:
var value = field.getValue ();

I think all of this is documented in the Programmers Reference Guide, but I cannot be sure.

So:
if (parser.getField ("status").getValue () == "Complete")
$("#" + parser.m_widgetInfo.wrapperId).find (".aw-form-buttons .k-primary.k-button").css ("display", "none");
Aware IM Support Team
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: Hide Save Form Button

Post by johntalbott »

I haven't tried this, but something along these lines should work ...

The Form parser has getField function that takes the AttributeName and FormSectionName as parameters and returns a field object. Then you can field value for your condition check.

1. Include the "status" field on the form. Hide it if you don't want it to be displayed.
2. Get the "status" field from the parser
3. Get the value of the "status" field
4. If the "status" field = "Complete", hide the Save button

***Render Script***

var field = parser.getField (“status”, “Main”);
var value = field.getValue ();

If (value == "Complete") {

$("#" + parser.m_widgetInfo.wrapperId).find (".aw-form-buttons .k-primary.k-button").css ("display", "none");

}
VocalDay Solutions - Agility - Predictability - Quality

We specialize in enabling business through the innovative use of technology.

AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: Hide Save Form Button

Post by johntalbott »

Yeah ... what he said. :lol:
VocalDay Solutions - Agility - Predictability - Quality

We specialize in enabling business through the innovative use of technology.

AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
BLOMASKY
Posts: 1473
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Hide Save Form Button

Post by BLOMASKY »

Thanks John!

Thanks AwareSupport!

I guess I have to re-read the programmers reference again. I hate asking questions that are answered in the documentation.

Back to reading....

Bruce
Post Reply