how to save results of batch editing, all rows, all cells

9 posts, 0 answers
  1. StringTheory
    StringTheory avatar
    8 posts
    Member since:
    Dec 2006

    Posted 07 Apr 2014 Link to this post

    Hi,
    In reading the documentation here:

    http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html

    I see this:
     CautionWhen setting the EditMode to Batch multi-row editing is not supported as only one editor is initialized for a given column(for performance purposes).

    This caution would seem to defeat the purpose of batch (Excel-like) editing.

    I'm trying to find a way to save the new values for all rows and all cells that have the red triangle on them as the result of batch editing. As it is now, I can only retrieve the values from the cell that is currently having an edit made. 

    Here is the start of my code. Perhaps it's not firing on the proper event.

    Protected Sub RadGrid1_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
     
        Dim argument As Telerik.Web.UI.GridBatchEditingEventArgument = TryCast(e.CommandArgument, Telerik.Web.UI.GridBatchEditingEventArgument)
        Dim oldValues As Hashtable = argument.OldValues
        Dim newValues As Hashtable = argument.NewValues

    Thanks in advance.
  2. StringTheory
    StringTheory avatar
    8 posts
    Member since:
    Dec 2006

    Posted 07 Apr 2014 in reply to StringTheory Link to this post

    update: I can now iterate through all the rows that have gotten updated, but am still struggling to figure out which field in the row was updated. According to numerous posts by Telerik staff, the standard way to retrieve oldValues is as noted above (Dim oldValues as hashtable=argument.OldValues). However, I cannot retrieve anything from oldValues. 

    I can see the new values via newValues("theField").toString.

    I cannot see oldValues via a similar call: oldValues("theField").toString

     FYI this is the starting portion of the function which iterates through the changed rows. 
    Protected Sub RadGrid1_ItemCommand(sender As Object, e As Telerik.Web.UI.GridBatchEditingEventArgs)    
    For Each command As Telerik.Web.UI.GridBatchEditingCommand In e.Commands
             If command.Type = Telerik.Web.UI.GridBatchEditingCommandType.Update Then
                 Dim oldValues As Hashtable = command.OldValues
                 Dim newValues As Hashtable = command.NewValues
    ...

    One other note for Telerik dev's: Let me know if I should post this as a bug, but if I am in batch edit mode, and simply click my mouse in a dropdown list in a row, but don't change it, and click Update, then that row gets added to the hashtable.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 10 Apr 2014 Link to this post

    Hi,

    When using Batch editing mode for RadGrid the ItemCommand, UpdateCommand, DeleteCommand, InsertCommand are fired multiple times for every change made on the client. If you would like to access the value in given column for the currently updated item you could use the column UniqueName.

    For your convenience I have prepared a sample project with Batch editing mode in RadGrid where Update and Insert commands are implemented. Try using similar approach for updating values with Batch editing.

    Regards,
    Viktor Tachev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Snehal
    Snehal avatar
    1 posts
    Member since:
    Aug 2014

    Posted 07 Nov 2014 in reply to Viktor Tachev Link to this post

    Hi ,
       I am facing save issue . still not able to update records to database.
       I guess    Hashtable oldValues = command.OldValues;  maintains values of only for GridBoundColumn not   for GridTemplateColumn ,because  I am  also not getting all the grid column in OLDVALUES collection.
    please correct me if i am wrong .

       I tried the solution attached (RadGridBatchEditingSample.zip)  at my end,  but still no luck .
        First of all "RadGrid1_UpdateCommand " event is not getting fired .Only the event which is fired is      "RadGrid1_BatchEditCommand"   and in RadGrid1_BatchEditCommand   event     i tried following code  
              GridEditableItem editedItem = e.Item as GridEditableItem;
              DataSet newData = FillView(); //  this return dataset which is bind to grid 
              DataRow[] data = newData.Tables[0].Select("RequestID = " +              editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["RequestID"].ToString());

       Its returning me null , even though cell are marked in red color .

          I also tried to read the  values  directly  by UniqueName   ..  but hard luck . struggling with same problem from last 2 days
      kindly assist.















  6. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 11 Nov 2014 Link to this post

    Hi Snehal,

    The behavior you describe seems strange. I tried to replicate the issue, however, I was unable to. I modified the previous sample so that one of the columns is GridTemplateColumn. Still, the data is updated as expected on my end.

    Give the attached sample a try and let me know how it works for you.

    Regards,
    Viktor Tachev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Supachai
    Supachai avatar
    3 posts
    Member since:
    Oct 2014

    Posted 23 May 2015 Link to this post

    Hi Viktor,

    I followed your RadGridBatchEditingSample.zip. It is working when I use "save changes" from default command button. But it does not work when I click update button from CommandItemTemplate. Could you advice me how to make the same behavior in your sample work with button in CommandItemTemplate.

     Regards,

    Supachai.

  8. Supachai
    Supachai avatar
    3 posts
    Member since:
    Oct 2014

    Posted 23 May 2015 in reply to Supachai Link to this post

    For more information about my problem. When I click update button from CommandItemTemplate. I got "Unable to cast object of type 'System.String' to type 'Telerik.Web.UI.GridBatchEditingEventArgument'" on UpdateCommand event handler.
  9. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 26 May 2015 Link to this post

    Hello Supachai,

    In order to save the changes in RadGrid with a Button control that us different than the default one you should use the following approach.

    Handle the OnClientClick event of the Button and call the client-side saveChanges() method for the GridTableView.

    The following code snippets illustrate the approach.

    CommandItemTemplate markup:

    <CommandItemTemplate>
        <asp:Button Text="Save Changes" runat="server" OnClientClick="saveChanges(this, event); return false;" />
    </CommandItemTemplate>

    JavaScript handler:

    function saveChanges(sender, args) {
        var grid = $find("<%= RadGrid1.ClientID %>");
        var masterTableView = grid.get_masterTableView();
        var batchEditingManager = grid.get_batchEditingManager();
     
        batchEditingManager.saveChanges(masterTableView);
    }


    In addition I am attaching the sample project with applied modifications.


    Regards,
    Viktor Tachev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  10. Supachai
    Supachai avatar
    3 posts
    Member since:
    Oct 2014

    Posted 27 May 2015 in reply to Viktor Tachev Link to this post

    Thank you Viktor. This is what I really want to know.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017