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

Insert Record on Tab

1 Answer 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RvdGrint
Top achievements
Rank 1
RvdGrint asked on 13 Sep 2011, 02:37 PM
Hello,

I've a RadGrid with EditMode="InPlace". The Grid is based on a DataTable as datasource. When pressing tab on de last field of the last record I would like to update/insert the current and add a new record.
Is that possible with a RadGrid and if so can someone provide me with a sample?

Regards,
  Jos Meerkerk

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 16 Sep 2011, 07:47 AM
Hi Jos,

 You can fire such a command on the client using the fireCommand function of the MasterTableView. But this will only work for one command at a time. Because each you fire a command the page refreshes and the grid reloads that's why two consecutive command cannot be fired at the same time. Another option would be to fire a custom command (fireCommand("MyCustomCommand")). And then handle this in the ItemCommand event of the grid. Then you can execute the logic for saving the record and additionally put the Grid in insert mode by setting: RadGrid1.MasterTableView.IsItemInserted = true; The last part that remains is to hook up the onblur event for the last field of the last record in the grid. You can do this either in the ItemCommand or the PreRender event when the item is already in edit mode. Then you can access the last control (presumably a textbox) as shown in this help topic and wire up the onblur event to it: 

GridDataItem item = RadGrid1.Items[RadGrid1.Items.Count - 1];
 
        if (item is GridEditableItem && (item as GridEditableItem).IsInEditMode)
        {
            TextBox txb = item["LastColumnUniqueName"].Controls[0] as TextBox;
            txb.Attributes["onblur"] = "myFunction(); return false";
        }


Greetings,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Tags
Grid
Asked by
RvdGrint
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or