Batch Cell edit does not fire events?

7 posts, 0 answers
  1. Stefan
    Stefan avatar
    58 posts
    Member since:
    Jan 2013

    Posted 28 Jun 2013 Link to this post

    I have a radgrid in batch cell edit mode using advanced databinding and I can not get any of the itemUpdate, itemDeleted itemCommand to fire?  Does batch editing not work with advanced databinding?  Wiill it only work with a datasource??

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1798 posts

    Posted 03 Jul 2013 Link to this post

    Hi Stefan,

    Thank you for contacting us.

    I am attaching a sample project with Batch Cell edit mode and advanced data binding.

    Please note that although the above scenario works, the events you have mentioned won`t fire and this is expected behavior. The mentioned server events fire only in case automatic DataSource operations are performed. See the help topics below for more information on this matter:


      The list below presents the events that would fire on batch cell edit mode:
    • UpdateCommand
    • InsertCommand
    • DeleteCommand
    • ItemCommand
    • BatchEditCommand

    Notwithstanding, you can easily use BatchEditCommand event for your database manipulations as shown in the attached project.


      Best Regards,
      Konstantin Dikov
      Telerik
      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 the blog feed now.
    • UI for ASP.NET Ajax is Ready for VS 2017
    • Stefan
      Stefan avatar
      58 posts
      Member since:
      Jan 2013

      Posted 03 Jul 2013 Link to this post

      thanks this looks like it may work.  Can i get the VB version for this part please.

          {
              for (int i = 0; i < e.Commands.Count; i++)
              {
                  var currentCommand = e.Commands[i];
                  if (currentCommand.Type.ToString() == "Update")
                  {
                      String ConnString = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
                      SqlConnection conn = new SqlConnection(ConnString);
                      SqlDataAdapter adapter = new SqlDataAdapter();

                      string updateCommandStr = String.Format("Update Territories SET TerritoryDescription='{0}' WHERE TerritoryID='{1}'"
                              , currentCommand.NewValues["TerritoryDescription"], currentCommand.NewValues["TerritoryID"]);

                      conn.Open();
                      SqlCommand updateCommand = new SqlCommand(updateCommandStr, conn);
                      updateCommand.ExecuteNonQuery();

                      currentCommand.Item.Edit = false;
                  }

                  // Same for Insert and Delete batch commands
              }
          }

    • Stefan
      Stefan avatar
      58 posts
      Member since:
      Jan 2013

      Posted 03 Jul 2013 Link to this post

      Also one last thing, how can I get this programtically created column to show as a command in the BatcheditCommand?

                  Dim oDeleteColumn As New GridButtonColumn

                  If True Then
                      With oDeleteColumn
                          .UniqueName = "Delete"
                          .HeaderText = "Remove"
                          .ItemStyle.Font.Size = 8
                          .ButtonType = GridButtonColumnType.ImageButton
                          .ImageUrl = "~/Images/style7/cancel.gif"
                          .Display = True
                          .Visible = True
                          .CommandName = "Delete"
                          .CommandArgument = "Delete"
                          .ConfirmText = "Delete this increment?"
                          .ConfirmDialogType = GridConfirmDialogType.RadWindow
                          .ItemStyle.HorizontalAlign = HorizontalAlign.Left
                      End With

                  End If

                  With dgCompNonGrid
                      .MasterTableView.Columns.Add(oDeleteColumn)
                      .MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top
                      .MasterTableView.BatchEditingSettings.EditType = GridBatchEditingType.Row
                  End With

      When I click the image with the X it removes the row from the grid but does not fire the BatchEditCommand event so I have no way of deleting the row from the database.  I tried setting the CommandName and CommandArguement but it does not fire the BatchEditCommand event?

    • Konstantin Dikov
      Admin
      Konstantin Dikov avatar
      1798 posts

      Posted 05 Jul 2013 Link to this post

      Hello Stefan,

      Thank you for getting back to us.

      For your convenience I am attaching the whole project with VB, not only the part that you asked for. I have also included your delete column and an if statement for the "Delete" batch command.

      About your concerns that BatchEditCommand event is not firing on row deletion, I want to inform you that this is due to the fact that you have to click on the Save changes button in order to fire the event. The main goal of Batch edit mode is to provide functionality for inline client-side editing, performing multiple changes before applying them.

      If we can be of any further assistance, don`t hesitate to contact us again. 

      Regards,
      Konstantin Dikov
      Telerik
      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 the blog feed now.
    • Massimiliano
      Massimiliano avatar
      184 posts
      Member since:
      Oct 2012

      Posted 13 Jul 2013 Link to this post

      I read that with batch editing active "normal" even are intercepted and redirected client side (just like the delete event mentioned above).
      Is there a way to prevent this? I mean is there a way to mix standard delete for example, batch editing when double clicking on a cell, normal editing when clicking on the edit command button?

      This would be great since batch editing may apply only to the limited set of fields shown in the grid while a complete editing could require a form to be opened in the grid.
    • Konstantin Dikov
      Admin
      Konstantin Dikov avatar
      1798 posts

      Posted 18 Jul 2013 Link to this post

      Hi Massimiliano,

      There is no build-in functionality that would allow you to combine batch edit mode with other edit modes. However, if you are using Cell edit type on Batch edit mode, you could add EditCommandColumn that will allow you to edit the row instead of the cell. 

      If you have any other questions, please feel free to get back to us.

       

      Regards,
      Konstantin Dikov
      Telerik
      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 the blog feed now.
    Back to Top
    UI for ASP.NET Ajax is Ready for VS 2017