3.0.5

What events fire for the Checkbox Template in a Grid?

I'm attempting to use an AW.Templates.Checkbox in a Grid. I cannot get any events to fire from the Templates.

<script>
var myData = [
    [false,true],
    [true,false],
];

var myColumns = [
    "CB 1", "CB 2"
];
var obj = new AW.Grid.Extended;
var cbx = new AW.Templates.Checkbox;

cbx.onControlValueChanged = function(){alert("onControlValueChanged")};
cbx.onCellValueChanged = function(){alert("onCellValueChanged")};
cbx.onCellValidated = function(){alert("onCellValidated")};
cbx.onControlClicked = function(){alert("onControlClicked")};
cbx.onClick = function(){alert("onClick")};

obj.setCellTemplate(cbx,0);
obj.setCellTemplate(cbx,1);

obj.setCellText(myData);
obj.setHeaderText(myColumns);
obj.setRowCount(2);
obj.setColumnCount(2);
obj.setSelectorVisible(false);
obj.setSelectorWidth(28);
obj.setHeaderHeight(20);
obj.setCellEditable(true);
obj.setVirtualMode(false);

document.write(obj);
</script>


None of these fire when a checkbox is clicked.

The only way I have found to attach to an event from checking the checkbox is to use:
obj.onCellValueChanged = function(){alert("obj.onCellValueChanged")};


This is not sufficient, though, because obj.onCellValueChanged is called when the data is being loaded into the grid, not only when someone has just clicked on the Checkbox. Also, since this event is attached to the Grid, and not a specific Template or column, it fires when any cell value changes, not just when a Checkbox is clicked.

I use obj.onCellValidated to invoke my save method, and that event does not fire when a checkbox is clicked.

This is driving me nuts, any advice or help is appreciated.
John
January 12,
Events fire on control (obj) and not on the template (cbx). The event handler is called with event/value/text, columnIndex, rowIndex arguments, so you can get back to the cell which triggered event.

http://www.activewidgets.com/aw.ui.grid/cell-edit-events.html
http://www.activewidgets.com/aw.ui.grid/cell-mouse-events.html

onCellValidated is fired when there is text-to-value conversion, so it is not applicable to the checkbox template, which changes cell value directly. So the right event is onCellValueChanged.
Alex (ActiveWidgets)
January 13,

This topic is archived.

See also:


Back to support forum