onSQLRefreshRowQuery Event


Fires when the Grid needs to select the current row in the Grid to refresh it.


Executes whenever the data in the current row of the Grid needs to be refreshed. Your event handler can take over the responsibility of returning a resultset that contains the data for the current Grid row.

If your Grid is based on a stored procedure you must write code for this event to return a resultset for the current Grid row. The primary key for the current Grid row will be passed into the event handler.

The 'e' object that is passed into the event handler contains the value of each primary key column for the current row.

For example, say that the primary key for the table that the Grid is based on is based on two columns. You can get the value of each primary key column using this code:


Here is a sample event handler your might create:

function onSQLRefreshRowQuery as v (e as p)

    dim flag as L
    flag = e.cn.execute("exec myRefreshRowStoredProcedure @pkvalue = :PKValue_1")
    if flag = .t. then 
        e.resultset = e.cn.resultSet
        e.handled = .t.
        e.fatalError = .t.
        e.errorText = "Could not refresh row. " + e.cn.callResult.text
    end if 

end function

Event Arguments & Properties

The following variables are available to you in the event:


The grid component definition


Run-time calculations (allows you to pass data to other event handlers)


State information


The SQL::Connection object for the Grid. You can call this object's .execute() method to execute your own SQL.


The SQL Statement that Alpha Anywhere has computed to get the data to refresh the row.


The SQL::Arguments object with values for all of the arguments in e.sql. To read a value from arguments: e.arguments.find("argumentName").data

e.arguments contains values for each column in the current record's Primary Key. For example if the Primary Key has 2 columns, then you can get the values for these columns as follows:

e.arguments[e.arguments.argumentNumber("pkvalue_1")].data  - value of first Primary Key column
e.arguments[e.arguments.argumentNumber("pkvalue_2")].data  - value of second Primary Key column

Your event must set the following properties:


Set to .t. if your event has returned the resultset to use


A SQL::ResultSet of records to show in the Grid (need only be set if e.handled is set to .t.)

Your event can optionally set these properties of the e object:


Set to .t. if a fatal error has occurred


The error text to show if a fatal error occurred

Setting State Variables

You can also set state variables in this event. The value of any state variables will be available in all subsequent ajax callbacks (in the e.__si2 object).

To set a state variable:

e._state.myvar1 = "value1"
e._state.myvar2 = "value2"