Welcome Guest Search | Active Topics | Sign In | Register

How do you programatically add a customcolumn to a grid Options
Joan Darling
Posted: Tuesday, June 14, 2016 10:47:55 AM
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?
eo_support
Posted: Wednesday, June 15, 2016 10:05:59 AM
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!
Joan Darling
Posted: Wednesday, June 15, 2016 3:28:29 PM
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?
eo_support
Posted: Thursday, June 16, 2016 10:10:30 AM
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!
Joan Darling
Posted: Thursday, June 16, 2016 4:26:37 PM
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) });


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.