# Grid problem

**URL:** <https://www.dynamicsuser.net/t/grid-problem/28452>\
**Category:** Developer Forum\
**Created:** [December 27, 2010, 10:58am UTC](https://www.dynamicsuser.net/t/grid-problem/28452 "2010-12-27T10:58:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishekusoni](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@abhishekusoni](https://www.dynamicsuser.net/u/abhishekusoni)\
**Post date:** [December 27, 2010, 10:58am UTC](https://www.dynamicsuser.net/t/grid-problem/28452/1 "2010-12-27T10:58:14Z")

</div>

Hello,

I have a grid which have two fields.

1. Lookup

2. 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

---

<div class="post-metadata">

**Author:** ![kranthi](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@kranthi](https://www.dynamicsuser.net/u/kranthi)\
**Post date:** [December 27, 2010, 11:30am UTC](https://www.dynamicsuser.net/t/grid-problem/28452/2 "2010-12-27T11:30:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![abhishekusoni](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@abhishekusoni](https://www.dynamicsuser.net/u/abhishekusoni)\
**Post date:** [December 27, 2010, 12:06pm UTC](https://www.dynamicsuser.net/t/grid-problem/28452/3 "2010-12-27T12:06:41Z")

</div>

Thanks Kranthi, but unfortunately it does not works…!!! I have tried it with both before and after Super().

Abhishek

---

<div class="post-metadata">

**Author:** ![sivasenthilram](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@sivasenthilram](https://www.dynamicsuser.net/u/sivasenthilram)\
**Post date:** [December 27, 2010, 12:26pm UTC](https://www.dynamicsuser.net/t/grid-problem/28452/4 "2010-12-27T12:26:03Z")

</div>

FORMDATASOURCESNAME\_ds.object(fieldnum(ACTUALTABLE,FIELDName)).allowEdit(ACTUALTABLE.lookupfied != “1”);

TRY OUT IN ACTIVE method in Datasources.SAVE and restore

---

<div class="post-metadata">

**Author:** ![abhishekusoni](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@abhishekusoni](https://www.dynamicsuser.net/u/abhishekusoni)\
**Post date:** [December 27, 2010, 12:30pm UTC](https://www.dynamicsuser.net/t/grid-problem/28452/5 "2010-12-27T12:30:54Z")

</div>

Thanks RAM…Not WORKS…Save and restore both table and form…but not works…there is no restore option on dataSource…!!!

---

<div class="post-metadata">

**Author:** ![kranthi](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@kranthi](https://www.dynamicsuser.net/u/kranthi)\
**Post date:** [December 27, 2010, 1:10pm UTC](https://www.dynamicsuser.net/t/grid-problem/28452/6 "2010-12-27T13:10:42Z")

</div>

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;

}

---

<div class="post-metadata">

**Author:** ![David\_Kidder](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@David\_Kidder](https://www.dynamicsuser.net/u/David_Kidder)\
**Post date:** [December 29, 2010, 3:37pm UTC](https://www.dynamicsuser.net/t/grid-problem/28452/7 "2010-12-29T15:37:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kranthi](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@kranthi](https://www.dynamicsuser.net/u/kranthi)\
**Post date:** [December 29, 2010, 3:54pm UTC](https://www.dynamicsuser.net/t/grid-problem/28452/8 "2010-12-29T15:54:31Z")

</div>

As david said call the same method (enableFields()) in the modified method of the lookup field…

---

<div class="post-metadata">

**Author:** ![imranazami](https://avatars.discourse-cdn.com/v4/letter/i/f9ae1b/32.png) [@imranazami](https://www.dynamicsuser.net/u/imranazami)\
**Post date:** [December 30, 2010, 4:19am UTC](https://www.dynamicsuser.net/t/grid-problem/28452/9 "2010-12-30T04:19:29Z")

</div>

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;  
}
