Hello,
I have a grid which have two fields.
Lookup
StringEdit.
What I want is, when I change lookup and the selected value is “1” then I want the another stringEdit should be disabled…else enabled…
It seems so simple, but I can’t fins it out.
Can you help me…??
Abhishek
kranthi
December 27, 2010, 11:30am
2
Table_ds.object(fieldnum(Table,StringField)).allowEdit(Table.lookupfied == “1”);
put the above code in the active method of the form datasource.
hope both are the fields from data source.
Thanks Kranthi, but unfortunately it does not works…!!! I have tried it with both before and after Super().
Abhishek
FORMDATASOURCESNAME_ds.object(fieldnum(ACTUALTABLE,FIELDName)).allowEdit(ACTUALTABLE.lookupfied != “1”);
TRY OUT IN ACTIVE method in Datasources.SAVE and restore
Thanks RAM…Not WORKS…Save and restore both table and form…but not works…there is no restore option on dataSource…!!!
kranthi
December 27, 2010, 1:10pm
6
Try by adding a new method to the form methods
void enableFields()
{
Table_ds.object(fieldnum(Table,StringField)).allowEdit(Table.lookupfied == “1”);
}
and call this method in active method
public int active()
{
int ret;
ret = super();
element.enableFields(); // call the method here
return ret;
}
The code that is being suggested to be placed in active() should work to set the property appropriately as you move between records in the grid, however, you will also need that code in the modified() override on the “Lookup” DataSourceField to account for the case where the user changes the value in the lookup.
kranthi
December 29, 2010, 3:54pm
8
As david said call the same method (enableFields()) in the modified method of the lookup field…
Hi Abhishek,
Override ‘modified method’ of the lookup field. Use the following code
public boolean modified()
{
boolean ret;
if (TestTable_LookupField.text() == “1”)
{
TestTable_StringEdit.enabled(false);
}
else
{
TestTable_StringEdit.enabled(true);
}
ret = super();
return ret;
}