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

Tab to next row.

3 Answers 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lukus
Top achievements
Rank 1
Lukus asked on 20 Jul 2011, 05:12 PM
Hello,

I am editing my grid inline one row at a time.  Is there a way to make it so my users can tab out of the last editable column of one row and automatically start editing the next row? In other words, take the row I was in and commit it to the db onBlur and  move the next row into edit mode.

3 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 26 Jul 2011, 11:30 AM
Hello Lukus,

 In order to achieve this you will have to handle the onBlur event for the last TextBox of the edited row. You can do this in the ItemCreated / ItemDataBound event of RadGrid and then access the TexBox and attach the event:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                TextBox txb = (e.Item as GridEditableItem)["lastColumn"].FindControl("myTextBox") as TextBox;
                txb.Attributes["onblur"] = "txbBlur("+e.Item.ItemIndex+");return false";
            }
        }

You can pass the index of the edited item so that it can be retrieved and modified properly on the client. You can make use of RadGrid client-side API if you need to update and edit items on the client. Note that calling the updateItem or editItem client-side methods of the masterTablewView might require a postback so that the grid layout can be changed. So you might need to first call one of them (e.g. updateItem) and after the page has refreshed put the item in edit mode.

var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
                var currentItem = masterTable.get_dataItems()[index];
                var nextItem = masterTable.get_dataItems()[index + 1];
                masterTable.updateItem(currentItem.get_element());
                //page posts back and then put the item in edit mode
                masterTable.editItem(nextItem.get_element());

All the best,
Marin
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Peter
Top achievements
Rank 1
answered on 02 May 2012, 03:30 AM
How do I rebind the grid after this event fires? 

After "masterTable.editItem(nextItem.get_element());" fires, my grid goes blank. Presumably because it needs to rebind.
0
Iana Tsolova
Telerik team
answered on 02 May 2012, 09:05 AM
Hello Peter,

When edit command is fired the grid is implicitly rebound. If you are using binding the grid through the NeedDataSource event, there's no need to rebind it explicitly. But if you are using simple data binding, you need to make sure you are assigning DataSource and calling DataBind() on edit command. See the below resources for more information:
http://www.telerik.com/help/aspnet-ajax/grid-advanced-data-binding.html
http://www.telerik.com/help/aspnet-ajax/grid-simple-data-binding.html
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/needdatasource/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/simplebinding/defaultcs.aspx

Greetings,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Lukus
Top achievements
Rank 1
Answers by
Marin
Telerik team
Peter
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or