Luegisdorf
12/13/2005 10:06:00 AM
Hi Michael
Your're right; In Axapta 2.5 the Grid controls hasn't a controlNum() method.
I see to possiblitities to make your desired functionality run:
a) add the controls in the grid manually instead using autoDataGroup, auto
declare each of them and access direct to the field controls instead with the
grid.
b) If you want use a autoDataGroup: design an empty grid and add the fields
at runtime at form startup to the grid using an iteration of the fieldgroup's
fields. You can now use controlNames like "gridCtrl_1" and can access with
"gridCtrl_" + <any valid number>.
That's the only two possiblities I see in Axapta 2.5. Solution a) is faster
done, but solution b) is more dynamicly.
Best regards
Patrick
"Michael" wrote:
> Hi Patrick
>
> I am sorry, but I forgot to mention that it is in Ax 2.5.
>
> Since its working in 3.0, thats probably why none of the examples I found
> would work.
>
> Do you have any ideas how I could get it to work in Ax2.5?
>
> Thanks,
> Michael
>
> "Luegisdorf" wrote:
>
> > Hi Michael
> >
> > I tried your example just with the 'Address' form and it works well:
> >
> > 1. Goto the AOT and to the form Address
> > 2. Make the grid on the form Autodeclartion=true
> > 3. Add a Button
> > 4. The clicked Button on the form should look like this:
> > oid clicked()
> > {
> > Object parentControl, childcontrol;
> > ;
> > parentControl = grid;
> > childControl = grid.controlNum(1);
> > childControl.visible(false);
> >
> > }
> > 5. Open the form and click the button
> > 6. Effect should be, that first Column will be moved out (invisible)
> >
> > If this this does not work with your Axapta, may be it is a version problem;
> > with what Version and Service Pack you work? I'm using Axapta 3.0 with SP4.
> >
> > Best regards
> > Patrick
> >
> >
> > "Michael" wrote:
> >
> > > Hi
> > >
> > > I have a problem that I haven't been able to find the answer to anywhere.
> > >
> > > Basically what I am doing is the following:
> > >
> > > I have a form containing a grid. Most of the different customers using this
> > > form always wants changes to the grid, which is why I decided on the solution
> > > below.
> > >
> > > From this form they can click on a dialog to enable/disable(visible or not)
> > > the different fields on the grid.
> > >
> > > I have now made it so that I build the dialog by running through the
> > > elements of the grid in run time.
> > >
> > > I am able to get all the properties without any problems. But when they
> > > click disable on the dialog and I want to get that change effective(runtime)
> > > in the grid-element it doesn't show/hide the element, even though in the
> > > debugger I can see it changing before and after. Here's the code:
> > >
> > > ------------------------
> > > Object parentControl, childcontrol;
> > > ;
> > > ...
> > > parentControl = element.form().design().control(TmpGrid.id());
> > > childControl = parentControl.controlNum(UserSettings.Position);
> > > childControl.visible(UserSettings.visible);
> > >
> > > // I have tried all these but noone of them seem to work:
> > > element.redraw();
> > > this.redraw();
> > > element.refresh();
> > > ------------------------
> > >
> > > I really hope someone can help me with this, because I am almost considering
> > > going back to the old crappy solution where its not dynamic.
> > >
> > > Thanks
> > > Michael