Mae
Mae

Reputation: 21

calling an event on a Button in datawindow

I have placed a search button on a datawindow, and i have already an event for searching such list...how is it possible to call an event once the button is clicked on runtime.

below is the code on my event named "ue_key"

    string xcode, iseries, ycode, sql_statement, xname, i_cname, name, iseries_no, irequested_by, irequest_problem, irequesting_dept, idate_request, idate_needed
    string iasset_no, idate_received, istatus
    long i_row
    //integer 

    i_cname = dw_work_order.getcolumnname()
    i_row = this.getrow()
    if i_row > 0 then
        if key = keyF2! and i_cname = 'series_no' then

            //open(w_csearch)   
            //  Then, define select statement
            sql_statement = "SELECT series_no as 'Series NO', requested_by as 'Requested By' FROM work_order_form where status = 'A' or status = 'ACTIVE';"

            str_sellist args
            args.trans = sqlca
            args.sel_cmd = sql_statement

            //  Specify which column will be the return value
            args.retcol = 1

            //  Define drop-down items.  NOTE:  This should correspond
            //  with the alias you use for the columns you retrieve
            args.dropdown_items[1] = "Series NO"
            args.dropdown_items[2] = "Requested By"

            //  Define Search Window Title
            args.title = "Work Order"

            //  Define transaction object for the window
            //  This is REQUIRE for now...  :)


        //  Open with parameter
            OpenWithParm(w_sellist, args)
            ycode=message.stringparm

            xcode = ycode
        //  MessageBox('test', xcode)
            if trim(xcode) <> '' then

                    select   series_no, requested_by, request_problem, requesting_dept, date_request,date_needed, asset_no, status                                    
                    into        :iseries, :irequested_by, :irequest_problem, :irequesting_dept, :idate_request, :idate_needed, :iasset_no, :istatus
                    From work_order_form where series_no = :xcode using sqlca;


    //  Messagebox('test', iseries)
            this.setitem(THIS.GETROW(),'series_no', iseries)
            this.setitem(THIS.GETROW(),'requested_by', irequested_by)
            this.setitem(THIS.GETROW(),'request_problem', irequest_problem)
            this.setitem(THIS.GETROW(),'requesting_dept', irequesting_dept)
            this.setitem(THIS.GETROW(),'date_request', idate_request)
            this.setitem(THIS.GETROW(),'date_needed', idate_needed)
            this.setitem(THIS.GETROW(),'asset_no', iasset_no)
            this.setitem(THIS.GETROW(),'status', istatus)

    //dw_work_order.retrieve(iseries)

            end if
        end if
    end if

Thanks a lot!

Upvotes: 2

Views: 1615

Answers (1)

The datawindow control has "ButtonClicking" and "ButtonClicked" events. You can use these event to identify which button was clicked (check the event arguments, specifically dwo.Name) and call the appropriate code.

You'll want to make sure that your datawindow button's action is set for "User Defined (0)".

Upvotes: 2

Related Questions