:: Forum >>

filtering characters into a cell

I would like to filter characters into a cell. In other words, I'd like to
attach a function to onkeypress and onkeyup events:

gridobj.getCellTemplate(3,1).setEvent("onkeypress", AllowOnlyLetters);

The problem is that the very first input into the cell
is not being filtered. Subsequent entries are. So
for example, if I type '1' into the grid, it appears in the cell.
I delete the '1' and attempt to type it again. It does not appear:
the expected behaviour. (Very odd!)
J Mansons
Sunday, June 4, 2006
I have observed why the code above has the odd
behaviour:
It looks like when I select a cell, the event handler is not
active. However, when I double-click on the cell, the event handler
is suddenly active.

Any reason why this is so?
J Mansons
Sunday, June 4, 2006
Normally the keyboard focus (and hence keyboard events) is attached to the grid control itself, not to the current cell.
Alex (ActiveWidgets)
Monday, June 5, 2006
So how can the problem above be resolved? Surely the idea of filtering input into a cell is not alien.... perhaps a solution would be to attach a handler to the grid and in the handler work out which cell I am in and accept or deny certain characters? This seems like a rather long way to achieve something rather simple... Is there an elegant solution?
Jack Mansons
Wednesday, June 7, 2006
The solution will be available in a couple of days with 2.0.1 release. You will be able to attach an event handler to the onCellTextChanging() event which fires with each keystroke (actually with any change in the textbox value, including copy/paste, drag and drop, etc.). If the new value does not fit your criteria you would simply cancel onCellTextChanging() event and the textbox value does not change. The same would work for maxlength filter.
Alex (ActiveWidgets)
Wednesday, June 7, 2006

This topic is archived.


Back to support forum

Forum search