Designer 10.7 | webMethods CAF and OpenUI Development | Understanding the Client-side Model | CAF.Table.Model | Listeners
 
Listeners
Custom client-side code can listen for changes to the table by registering table-change and row-change listeners. Table-change events are raised when the table is paged, or when its select-all or none state is toggled. Row-change events are raised when a row is added, removed, updated, or selected using the CAF.Table.Model.
Add a table-change listener using the addTableChangeListener(fn) method. Its one argument (fn) is the listener method; when a table-change event is raised the listener method is passed two arguments: the table ID and the event type such as page, select-all, or select-none.
Add a row-change listener using the addRowChangeListener(fn) method. Its one argument (fn) is also the listener method; when a row-change event is raised the listener method is passed three arguments: the table ID, the row ID, and the event type such as add, remove, or update, or select. The following example alerts the user when a row in the table is selected:
var table = CAF.model('#{activePageBean.clientIds['myTableId']}');
table.addRowChangeListener(function(tableId, rowId, eventType) {
if (eventType "select") {
var row = CAF.model(rowId);
if (table.isSelected(row))
alert(row.getValue() + " selected");
}
});
For more information about CAF controls, see the webMethods CAF Tag Library Reference, as described in Finding Information about CAF Controls.
Related Topics