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

Edit Item index is not cleared when insert item is clicked

3 Answers 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jason Miller
Top achievements
Rank 1
Jason Miller asked on 24 Feb 2011, 07:47 PM
When a Rad Grid is in edit mode, and the user clicks "Add New Record", the grid jumps to the last page and has the insert row, but the original edit index has not changed.  This causes the insert row to be at the top of the last page, and an editable row to also be on the last page.

Is there any way to clear the edit indices before the insert row is added.

I currently have AllowMultiRowEdit set to false , but that doesn't seem to do the trick.

Any help would be much appreciated,

Thanks!

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Feb 2011, 05:40 AM
Hello Jason,

Try the following code snippet in the ItemDataBound Event, which clears all the Edit forms when grid in in insert mode.
C#:
if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
       {
           RadGrid1.MasterTableView.ClearEditItems();
       }

Thanks,
Shinu.
0
Jason Miller
Top achievements
Rank 1
answered on 25 Feb 2011, 08:57 PM
Shinu,

That doesn't seem to be doing the trick.

Here is what I did:

VB:
Protected Sub rgSizeCharts_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgSizeCharts.ItemDataBound
        If TypeOf e.Item Is GridDataInsertItem And e.Item.OwnerTableView.IsItemInserted Then
 
            rgSizeCharts.MasterTableView.ClearEditItems()
        End If
 
    End Sub

It successfully enters the if block, but when it exists, the number of edit items has not changed, and the grid still shows an insert row, and an edit row.

Thanks!
0
Shinu
Top achievements
Rank 2
answered on 01 Mar 2011, 11:14 AM
Hello Jason,

Add the following code snippet in order hide editform when clicking insert and vice versa.

C#:
Protected Sub RadGrid1_ItemCommand(source As Object, e As GridCommandEventArgs)
    If e.CommandName = RadGrid.EditCommandName Then
        RadGrid1.MasterTableView.IsItemInserted = False
    End If
    If e.CommandName = RadGrid.InitInsertCommandName Then
        RadGrid1.MasterTableView.ClearEditItems()
    End If
End Sub

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