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

[Solved] Using the RadGrid as an excel sheet

1 Answer 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raph
Top achievements
Rank 1
Raph asked on 27 Jan 2010, 12:04 AM
Hi,

I'm using the Radgrid in some projects. I defined that i can eidt the items inline in the radgrid.

I pass from one field to the next one with the tab button. When I reach the last field, I would like to hit enter and that the row get saved.

To save, I have a method in the code behind.

How can I setup the grid to call the code behind saving method when enter get pressed?

I would like that it react like in SQL server management studio for example, passing from field to field with tab, and enter to save the data at the end of the line.

Is it possible with the grid? How can I do that?

Thanks already for xour help

Cheers,

R.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Jan 2010, 06:21 AM
Hello Raph,

You can add "onkeydown" event to the last column's textbox which will invoke button click when the user presses the enter key from keyboard. Try the following the code snippets.

CS:
 
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode) && !RadGrid1.MasterTableView.IsItemInserted) 
        { 
            GridEditableItem gridEditItem = e.Item as GridEditableItem; 
            TextBox stringTextBox = (TextBox)gridEditItem["LastColumnName"].Controls[0]; 
            Button btnUpd = (Button)gridEditItem.FindControl("UpdateButton"); 
            stringTextBox.Attributes.Add("onkeydown""if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnUpd.UniqueID + "').click();return false;}} else {return true}; "); 
        } 
    } 
 
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == RadGrid.UpdateCommandName) 
        { 
            // Update 
        } 
    } 

-Shinu.
Tags
Grid
Asked by
Raph
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or