ShowRowExpanderIcon Event
Description
This event fires when an existing row is rendered, if the row has a Row Expander. If the function returns .t., the Expander icon is show. Otherwise, it is hidden.
Discussion
This event allows you to hide the row expander icon for a row. For example, you can use this event to test if there would be any records to show in the Grid that appears in the Row Expander. If there are no records, you can hide the row expander icon.
Example
ShowRowExpanderIcon = .t.
The following variables are available to you in the event:
- Variable
- Description
- e.tmpl
The grid component definition
- e.rowData
Data for the current row. For example, to get the value of the 'lastname' field: e.rowData.data("lastname")
- e.conn
In the case of a Grid based on a SQL database, a pointer to an open connection.
Your event must set these properties:
- Property
- Description
- ShowRowExpanderIcon
If .t., the row expander will be shown. If .f., the row expander will be hidden.
Example for DBF
This example demonstrates how to show or hide the row expander icon for a Grid Component based on a DBF data source.
dim tbl2 as p tbl2 = table.open("invoices") dim i2 as p i2 = tbl2.query_create("","customerid = " + s_quote(e.rowData.data("customerId"))) if i2.records_get() = 0 then ShowRowExpanderIcon = .f. else ShowRowExpanderIcon = .t. end if
Example for SQL
This example demonstrates how to show or hide the row expander icon for a Grid Component based on a SQL data source.
dim sqltxt as c dim args as sql::arguments sqltxt = "select count(*) from invoices where customerid = :arg1" args.add("arg1",e.rowData.data("customerid")) e.conn.execute(sqltxt,args) dim count as n count = e.rtc.cn.resultset.data(1) if count = 0 then ShowRowExpanderIcon = .f. else ShowRowExpanderIcon = .t. end if
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"