This is a migrated thread and some comments may be shown as answers.

Control grid cell in edit mode

1 Answer 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raul
Top achievements
Rank 1
Raul asked on 30 Dec 2008, 09:53 AM
Hi all,

I have a grid, and I have designed edit template "input type=text" and in onkeypress text box I want to do these 2 actions:
1- validate input value to be number (I have done).
2- put this value in the next row text box (how to do?).
so anyway in javascript to control next edit row cells?
My code  below:

<telerik:GridTemplateColumn ColumnEditorID="GridTextBoxColumnEditor1"   
                                            DataField="start" HeaderText="start" SortExpression="start" UniqueName="start">  
                                            <EditItemTemplate> 
                                                <input id="Text1" style="width: 40px" type="text" onkeypress="return Bind(event)"/>  
                                            </EditItemTemplate> 
                                            <ItemTemplate> 
                                                <asp:Label ID="startLabel" runat="server" Text='<%# Eval("start") %>'></asp:Label> 
                                            </ItemTemplate> 
                                        </telerik:GridTemplateColumn> 
.  
.  
.  
.  
function Bind(e)  
                            {  
                                var keynum;  
                                var keychar;  
                                var numcheck;  
                                if(window.event) // IE  
                                {  
                                    keynum = e.keyCode;  
                                }  
                                else if(e.which) // Netscape/Firefox/Opera  
                                {  
                                    keynum = e.which;  
                                }  
                                keychar = String.fromCharCode(keynum);  
                                numcheck = /\d/;  
                                return numcheck.test(keychar);  
                            }  
 
 
 

Please advise

Regards

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 30 Dec 2008, 10:42 AM
Hello Raul,

You need to get a reference to the textbox in question. This can be done by using the client id, or by getting a particular cell, which hosts the textbox.
This online example shows another similar implementation.
I hope this gets you started properly.

All the best,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Raul
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or