Question Status

Verified
Wilson Chua asked a question on 19 Sep 2013 2:35 AM

I would like to know if i set a field 'enable' to no, but i wanted to set back the 'enable' to yes with some certain condition inside a simple screen.

For example, when the user choose an item type to "A", the checkbox will be enable or else disable.

How should i write the method? please guide me. thank you.

Reply
Verified Answer
Martin Dráb responded on 19 Sep 2013 5:04 AM

You can obtain a reference to the datasource field and use its enabled() method, e.g. YourDataSource_ds.object(fieldNum(YourTable, YourField)).enabled(true);.

Nevertheless if you actually wanted to set AllowEdit to No on table-field level, you wouldn't be able to re-enable it in a form.

Martin "Goshoom" Dráb | Freelancer | Goshoom.NET Dev Blog

Reply
Leandro Honório responded on 19 Sep 2013 5:03 AM

Hi,

The simplest way to do this is overriding active() on the form data source like this:

public int active()

{

   int ret;

   ret = super();

   Table_ds.object(fieldNum(Table, Field)).enabled(Table.ItemType == "A");

   return ret;

}

Notice that this will run only when you save or select the record on the form.

Regards,

Leandro H.

Reply
Verified Answer
Martin Dráb responded on 19 Sep 2013 5:04 AM

You can obtain a reference to the datasource field and use its enabled() method, e.g. YourDataSource_ds.object(fieldNum(YourTable, YourField)).enabled(true);.

Nevertheless if you actually wanted to set AllowEdit to No on table-field level, you wouldn't be able to re-enable it in a form.

Martin "Goshoom" Dráb | Freelancer | Goshoom.NET Dev Blog

Reply
Wilson Chua responded on 19 Sep 2013 9:40 PM

Thanks Martin, it solves my problem.

Reply