|
Rank: Advanced Member Groups: Member
Joined: 3/9/2010 Posts: 119
|
I need to add a textbox to the editortemplate of customcolumn so I can add javascript to the textbox to control key input. Do you have an example you can point me to?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
It will be much easier for you to use a TextBoxColumn instead. If you must use a CustomColumn, you must create an object that implements ITemplate and then assign it to the CustomColumn's EditorTemplate property. Implementing ITemplate is generic ASP.NET programming topic so we won't provide sample code but if you search online you should be able to find plenty of sample code for you.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 3/9/2010 Posts: 119
|
I wanted to use the textboxcolumn but didn't see any way to attach a function to the onkeydown event. Is there a way?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
There is no direct way to do this. However you can find out the client side id of the textbox and then manually hook up JavaScript code to handle onkeydown event. In the current implementation, the client side id of the textbox is in the form of GridClientID_ccolumnIndex_edit_tb. Here GridClientID is the client side ID of the Grid control, columnIndex is the zero based column index. So for example, for the second column of "Grid", it would be "Grid1_c1_edit_tb".
Hope this helps.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 3/9/2010 Posts: 119
|
Thanks, it works great! For others - this is the code I'm using
var txt = document.getElementById(idprefix + "grid_c4_edit_tb"); txt.addEventListener("keydown", function() { return validateKey(event, txt) });
|
|