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

adding records to DetailTable before setting into edit mode causing issues

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 05 Apr 2012, 03:49 PM
I have a RadGrid with a GridTableView inside the DetailTables.  This GridTableView has a LinkButton in it's CommandItemTemplate.  When this button is clicked it fires off the RadGrid1_ItemCommand  I set e.item.OwnerTableView.IsItemInserted = false to Reset any rows in insert mode.  I then add three records into a table that populates the DetailTable.   I then issue e.Item.Edit = True to put the rows into edit mode.  What I get is all my records displayed including the three I just added but only some of the fields are in edit mode (screenshot attached with new records highlighted).  I know my problem has something to do with needing to rebind the DetailTable but when I try to rebind the expanded DetailTable gets unexpanded and thrown out of edit mode.  How do you rebind the datasource of the GridTableView / DetailTable without causing it to collapse on the screen?
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
 
    sTableName = "" & e.Item.OwnerTableView.Name
 
    Select Case sTableName
        Case "Noms"
 
            Select Case e.CommandName
                Case "EditAll"
 
                    ' Edit All button pressed. Reset any rows in Insert mode
                    e.Item.OwnerTableView.IsItemInserted = False
 
                       'Code to add records to Database is here.
 
 
                    ' Put all rows in Edit mode
                    e.Item.Edit = True
 
            End Select
      End Select
End Sub


1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 10 Apr 2012, 09:16 AM
Hi,

Yes, you are  right about the Rebind. In order to preserve the expnaded/edited state of the items you should do this on the ItemDataBound event based on some flag, which you could set in the ItemCommand event.

Thus when you call Rebind operation you won't loose the expanded/edited state of the items. You could check this help topic for more information on how to access grid items in ItemDataBound event.

Regards,
Andrey
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
Steve
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or