The Web Forms version of the DataWindow is a subclass of the DataWindow .NET™ Web DataWindow control. The client-side programming capabilities of the Web DataWindow enable the use of client-side JavaScript event handlers.
The ClientEvent properties of the Web DataWindow have also been exposed, allowing the creation of customized event handlers that can override the default event handlers in the PBDataWindow.js file. The names of the ClientEvent properties consist of the name of a client-side event with an “OnClient” prefix. For example, the ClientEvent property that corresponds to the Clicked event would be OnClientClicked. You can circumvent the default event handler for the Clicked event by setting OnClientClicked to the name of a JavaScript function that uses the client-side Clicked event arguments.
The Web DataWindow client control supports the events listed in Table 3-2. The signatures of the client-side events and the effects of their return values are the same as for the Web DataWindow control in DataWindow .NET. For a description of each event, see “Alphabetical list of Web DataWindow client-side events”.
Event |
Arguments |
Return Codes |
---|---|---|
sender, rowNumber, buttonName |
0 – Continue processing |
|
sender, rowNumber, buttonName |
0 – Execute action assigned to button, then trigger ButtonClicked 1 – Do not execute action or trigger ButtonClicked |
|
sender, rowNumber, objectName |
0 – Continue processing1 – Prevent focus change |
|
sender, rowNumber, objectName |
0 – Continue processing1 – Prevent focus change |
|
sender, rowNumber, columnName, newValue |
0 – Accept data value 1 – Reject data value and prevent focus change 2 – Reject data value but allow focus change |
|
sender, rowNumber, columnName, newValue |
0 – Reject data value and show error message 1 – Reject data value with no error message 2 – Accept data value 3 – Reject data value but allow focus change |
|
sender, rowNumber, columnName |
0 – Continue processing |
|
sender, rowNumber, objectName |
0 – Continue processing1 – Prevent focus change |
|
sender, newRowNumber |
0 – Continue processing |
|
sender, currentRowNumber, newRowNumber |
0 – Continue processing 1 – Prevent focus change |
In client events, you can use a return statement as the last statement in the event script. The datatype of the value is number.
For example, in the ItemChanged event, set the return code to 2 to reject an empty string as a data value:
if (newValue = "") { return 2; }
This example prevents focus from changing if the user tries to go back to an earlier row:
function dwCustomer_RowFocusChanging(sender, currentRowNumber, newRowNumber) { if (newRowNumber < currentRowNumber) { return 1; } }
This example displays a message box informing the user which column and row number were clicked:
function dwCustomer_Clicked(sender, rowNumber, objectName) { alert ("You clicked the " + objectName + " column in row " + rowNumber) }
Note that displaying an Alert message box for all clicked objects in a DataWindow could prevent data entry or modification.