Grid Component - Checkbox Column - Custom Ajax Callbacks

Description

When you do a custom Ajax callback, the 'e' object that is passed into your Xbasic function that handles the callback contains a lot of useful information. Now, the 'e' object contains 3 additional properties that are automatically set if the grid has a checkbox column. The properties are:

  •  e.checkboxFilter

    a filter command to select all of the checked rows

  •  e.checkboxFilterArgumentXML

    (for SQL Grids only) if the Grid is based on SQL tables, the e.checkboxFilter property will use arguments (e.g. customerID = :pkValue1). This property contains the XML of the sql::arguments object. This object contains the argument value.

  •  e.checkboxFilterArgumentsEncoded

    (for SQL Grids only) contains an encoded version of the e.checkboxFilterArgumentXML property that can be used in the .gridFilterSet() method.

Example of the e.checkBoxFilter property for a .dbf table that has as its primary key, the expression 'firstname-lastname': (In this example, 3 records were checked)

(Firstname-lastname = "JanetRebo") .or. (Firstname-lastname = "BryanSmith") .or. (Firstname-lastname = "LarryDodds")

Example of the e.checkBoxFilter property for a .dbf table that uses record number as the primary key: (Again, the example assumes that 3 records were checked)

(recno() = 4) .or. (recno() = 7) .or. (recno() = 9)

Example of the e.checkBoxFilter property for a SQL table that has 'customer_id' as the primary key: (Again, the example assumes that 3 records were checked. Note that the filter uses arguments)

(CUSTOMER_ID = :PKValue_R1_1) OR (CUSTOMER_ID = :PKValue_R2_1) OR (CUSTOMER_ID = :PKValue_R3_1)

Example of the e.checkboxFilterArgumentXML property show the XML for the sql::arguments object. This has values for the 3 arguments used in the above filter expression.

<SQLArguments>
    <SQLArgument>
        <Name>pkvalue_r1_1</Name>
        <Data Type="N">2</Data>
        <IsNull Type="L">0</IsNull>
        <Usage>Input</Usage>
    </SQLArgument>
    <SQLArgument>
        <Name>pkvalue_r2_1</Name>
        <Data Type="N">3</Data>
        <IsNull Type="L">0</IsNull>
        <Usage>Input</Usage>
    </SQLArgument>
    <SQLArgument>
        <Name>pkvalue_r3_1</Name>
        <Data Type="N">4</Data>
        <IsNull Type="L">0</IsNull>
        <Usage>Input</Usage>
    </SQLArgument>
</SQLArguments>

Example of the e.checkboxFilterArgumentsEncoded property showing the encoded form of the above arguments:

2|||N|pkvalue_r1_1\n3|||N|pkvalue_r2_1\n4|||N|pkvalue_r3_1

Notice that the arguments are encoded into a string that is delimited with '\n' (the Javascript encoded value for a CRLF). The format is:

argumentValue|||argumentType|argumentName

The encoded arguments are useful if you want to use the .gridFlterSet() method in your callback function. For example, the code below shows how your Xbasic function could compute a Javascript command to return to the browser:

dim cmd as c
cmd =     "{grid.object}.gridFilterSet('" +\
          e.checkboxFilter + "','','" +\
          e.checkboxFilterArgumentsEncoded + ');"

The following videos demonstrate the new features checkbox features in the Grid: