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

[Solved] Editable grid with multirow edit and batch update

2 Answers 232 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cheryl
Top achievements
Rank 1
Cheryl asked on 25 Jul 2009, 07:21 PM

Hello,

I am trying to work with an editable grid where an item goes into edit mode with a double click and the updates are done in batch. The code is based loosely on the batch update sample project at http://www.telerik.com/help/aspnet-ajax/grdperformingbatchupdates.html.

When I edit an item and make changes, then double click another item to edit, the data chagned for the first item is lost. Is there a way to preserve the data and keep it displayed on the screen.

Thanks in advance!

 

function

 

RowDblClicked(sender, eventArgs) {

 

 

    var masterTable = $find("<%= RadGrid1.MasterTableView.ClientID %>");

 

 

    var selItem = masterTable.get_selectedItems()[0];

 

 

    if (selItem) {

 

        masterTable.editItem(selItem.get_element());

    }

}

 

<

 

telerik:RadGrid AllowMultiRowEdit="true" AllowMultiRowSelection="false"

 

ID

 

="RadGrid1" runat="server" OnItemCommand="RadGrid1_ItemCommand" >

 

 

    <MasterTableView DataKeyNames="OrderID,ProductID" CommandItemDisplay="Top" EditMode="InPlace">

 

 

    CommandItemTemplate>

 

 

        <asp:LinkButton ID="LinkButton1" CommandName="UpdateChanges" runat="server">Update all</asp:LinkButton>

 

 

    </CommandItemTemplate>

 

 

    </MasterTableView>

 

 

    <ClientSettings>

 

        <

 

Selecting AllowRowSelect="True"></Selecting>

 

 

        <ClientEvents OnRowDblClick="RowDblClicked" />

 

 

    </ClientSettings>

 

</

 

telerik:RadGrid>

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Jul 2009, 07:02 AM
Hi Cheryl,

One suggestion will be to store the Data in the Edit Form in a session and then in the PreRender event check whether the session is empty or not and then repopulate the Edit form with saved values from the Session. Here is the sample code to store the edited Data to the Session in the ItemCommand event while double clicking the Grid row.

CS:
 
 ArrayList editedItems; 
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (Session["EditedData"] == null
        { 
            editedItems = new ArrayList(); 
        } 
        else 
        { 
            editedItems = (ArrayList)Session["EditedData"]; 
        } 
        foreach (GridDataItem Item in RadGrid1.MasterTableView.Items) 
        { 
            if ((Item is GridEditableItem) && (Item.IsInEditMode)) 
            { 
                Hashtable values = new Hashtable(); 
                Item.ExtractValues(values); 
 
                editedItems.Add(values); 
                Session["EditedData"] = editedItems; 
            } 
        }  
       
    } 


Thanks
Shinu
0
Cheryl
Top achievements
Rank 1
answered on 29 Jul 2009, 06:12 PM
Thank you, Shinu.  That approach did not quite work, but we were able put the entire Dataset in the session. All grid actions hit that dataset.
Tags
Grid
Asked by
Cheryl
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Cheryl
Top achievements
Rank 1
Share this question
or