cancel
Showing results for 
Search instead for 
Did you mean: 

Button Control

Former Member
0 Kudos

Hi Guys,

Need some expert advice. I'm doing a check on wdinit whereby if there is no data for 'phone number' a button will get disabled. At the moment the button is set to enabled. How do i programitacilly disable the button? Thanks

Regards

Accepted Solutions (1)

Accepted Solutions (1)

abhijeet_mukkawar
Active Contributor
0 Kudos

Hi,

you need to do that in WdDoModifyView() method,

dont worry this will get called before view renders in browser

here do this:

lets say phoneNo is your context attribute where user need to fill phone no

if(wdContext.currenContextElement.getPhoneNo()==null)

//hope PhoneNo is of string type

{

IWDButton butObj = (IWDButton)view.getElement("Button1");

//Button1 is the id of button , check out its properties for this

but.setEnabled(false);

//this will make button enable false

}

put this code in modifyview method

hope it helps

regards

Former Member
0 Kudos

Thanks. I tried to add a similar code in wdinit and it just wouldnt allow. Didnt know that we should put it in the modify view. I'll try this one out and see how it goes.

abhijeet_mukkawar
Active Contributor
0 Kudos

hey buddy,

that code cant be put in WDDoInit(), you have to put that in WDModiFy(),

it will solve your problem i am damn sure

regards

abhijeet_mukkawar
Active Contributor
0 Kudos

hey Johan ,

have you solved your problem or not ?

let me know if you are facing any problem

regards

Former Member
0 Kudos

NO! Dont do it that way.

Use data binding (Button.enabled) or change the enabling state of the action itself. This could be preferable if there are more UI elements bound to this action that also should get enabled or disabled.

Armin

Former Member
0 Kudos

I am damn sure that this is not the way to go

Armin

abhijeet_mukkawar
Active Contributor
0 Kudos

hi,

Armin, will it create any performance problem or something? or when it is preferable?

regards

Former Member
0 Kudos

Setting UI element properties by data binding instead of using the setters from wdDoModifyView() has several advantages.

There might be more calls to wdDoModifyView() than you would expect. Using the setter on the UI element will invalidate the view layout such that some clients have to resend the complete view instead of only the changed data.

Armin

Answers (3)

Answers (3)

MG3
Contributor
0 Kudos

Hi Johan

Try this:

1. Create a boolean attribute,say 'enableButton' in your view's context.

2. Assign this attribute to your button's enable property.

3. In your view's wdDoInit method, write:


if(no data in phoneNumber)
        wdContext.<currentContextElement>().setEnableButton("false");

This should take care of your button enabling and disabling.

Thanks

Manoj

luciano_leitedasilva
Contributor
0 Kudos

Johan,

You have to create a context attribute, "btnEnable", with the type boolean and bind this attribute with the button's attribute "enabled".

At the wdInit, put this code to disable the button:

wdContext.currentContext().setBtnEnable(false);

Regards,

Luciano

Greg_Austin
Active Participant
0 Kudos

You have to bind the enabled property of the button to a context variable of type boolean. Setting the variable in your code will enable and disable the button.