Rabu, 03 Juni 2015

Passing value from parents form to child form

Morning SpAXrtan
Ohayou
Gunaydin

this time i share a steps how to get value from Parent form,wraped it become parameter,send to child form.

> Create a Display menuItem of child form
> Drag it to Parents form to become a button.
> Override the method click of menuItem button  

// #! INCIDENT !#.LAST.04.06.15.Husna.Yu:
//Menangkap nilai yang disortir digrid(diform parent),dijadikan parameter lalu dilempar ke form child
void clicked()
{
    /*
    Args                        args;
    FormRun                     formrun;
    super();

    args = new Args(formStr(PTGITTransaction));
    args.record(PTGITInventtable);
    formrun = classFactory.formRunClass(args);
    formrun.init();
    */

    Args                        parameters = new Args();
    MenuFunction                addressFormatmenu;
    ;

    addressFormatmenu = new MenuFunction(menuitemDisplayStr(PTGITTransaction),MenuItemType::Display);
    parameters.caller(element);
    parameters.parm(Grid_PTGItemcode.text());
    addressFormatmenu.run(parameters);

}

> on the datasource of childs form, overide the init method

// #! INCIDENT !#.LAST.04.06.15.Husna.Yu:
public void init()
{
    FormRun         callerForm = element.args().caller();
    super();

    if(callerForm)
    {
        if(callerForm.name() == formStr(PTGITInventtable))
        {
            //info(element.args().parm()); //cek parameter yang dilempar
        this.query().dataSourceNo(1).addRange(fieldNum(vwPTGITJournaltrans, PTGItemcode)).value(element.args().parm()); //memfilter record datasource agar menampilkan data sesuai parameter (element.args().parm())
        }
    }

}

done.

http://microsoft.public.axapta.programming.narkive.com/ZnRRSzzp/set-form-data-source-filter-from-x

Tidak ada komentar:

Posting Komentar

Erorr CS1963 - An expression tree may not contain a dynamic operation.

Kali ini saya mendapatkan erorr dengan code CS1963, padahal sebelumnya saya sudah mendefinisikan 'var item in Model' di @foreach(var...