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

Batch Cell edit does not fire events?

6 Answers 336 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 2
Stefan asked on 28 Jun 2013, 07:16 PM
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??

6 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 03 Jul 2013, 11:15 AM
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.
    0
    Stefan
    Top achievements
    Rank 2
    answered on 03 Jul 2013, 03:58 PM
    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
            }
        }

    0
    Stefan
    Top achievements
    Rank 2
    answered on 03 Jul 2013, 05:11 PM

    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?

    0
    Konstantin Dikov
    Telerik team
    answered on 05 Jul 2013, 11:59 AM
    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.
    0
    Massimiliano
    Top achievements
    Rank 1
    answered on 13 Jul 2013, 09:06 PM
    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.
    0
    Konstantin Dikov
    Telerik team
    answered on 18 Jul 2013, 10:19 AM
    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.
    Tags
    Grid
    Asked by
    Stefan
    Top achievements
    Rank 2
    Answers by
    Konstantin Dikov
    Telerik team
    Stefan
    Top achievements
    Rank 2
    Massimiliano
    Top achievements
    Rank 1
    Share this question
    or