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

OnDeleteCommand not triggering

4 Answers 166 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 05 Oct 2015, 10:16 PM

I am trying to run code behind when a row is deleted but am having trouble triggering OnDeleteCommand. It doesn't even seem like it is posting back which seems to be related to ajax but am not sure what I need to add or change to get it to trigger.

VB:

Protected Sub rgMfgLot_DeleteCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles rgMfgLot.DeleteCommand
       Try
           Dim lotNo As String = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("Lot_no").ToString()
           Dim dt As Data.DataTable = DirectCast(Session("StagedRecords"), Data.DataTable)
           Dim lineRow() As Data.DataRow
           lineRow = dt.Select("Lot_no = '" & lotNo & "'")
           dt.Rows.Remove(lineRow(0))
           dt.AcceptChanges()
           Session("StagedRecords") = dt
           BindSecondaryGrid()
       Catch ex As Exception
           Response.Write("<script type=""text/javascript"">alert(" + ex.Message + ");</script")
       End Try
   End Sub

 ASPX:

<telerik:RadGrid ID="rgMfgLot" runat="server" AllowPaging="false" CellSpacing="0" ShowFooter="false"
                            GridLines="None" OnPreRender="rgMfgLot_PreRender" OnItemCommand="rgMfgLot_ItemCommand"
                            OnBatchEditCommand="rgMfgLot_BatchEditCommand" OnItemDataBound="rgMfgLot_ItemDataBound"
                            OnBiffExporting="rgMfgLot_BiffExporting" OnDeleteCommand="rgMfgLot_DeleteCommand">
 
                            <MasterTableView CommandItemDisplay="TopAndBottom" EditMode="Batch" AutoGenerateColumns="false"
                                RetrieveNullAsDBNull="true" DataKeyNames="Lot_no">
                                <BatchEditingSettings EditType="Cell" />
 
                                <CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="True"
                                    ShowSaveChangesButton="false" ShowExportToExcelButton="false" ShowExportToCsvButton="false" />
                                <Columns>
                                    <telerik:GridNumericColumn DataField="Ord_no" HeaderText="Order #" UniqueName="Ord_no" ReadOnly="true">
                                    </telerik:GridNumericColumn>
 
                                    <telerik:GridNumericColumn DataField="Line_no" HeaderText ="Line_no" Visible="true" UniqueName="Line_no" ReadOnly="true" Display="False">
                                    </telerik:GridNumericColumn>
 
                                    <telerik:GridBoundColumn DataField="Item_no" HeaderText="Item #" UniqueName="Item_no" ReadOnly="true">
                                    </telerik:GridBoundColumn>
 
                                    <telerik:GridNumericColumn DataField="Container_cnt" HeaderText="Number of Containers" UniqueName="Container_cnt" DecimalDigits="0" ReadOnly="true" Display="false">
                                    </telerik:GridNumericColumn>
 
                                    <telerik:GridNumericColumn HeaderText="Qty to Receive" DecimalDigits="0" UniqueName="Qty_toreceive" DataField="Qty_toreceive">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                            <RequiredFieldValidator ForeColor="Red" ErrorMessage="Qty to Receive is required" ID="Qty_toreceiveVal"
                                                ValidationGroup="valGroup">                                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridNumericColumn>
                                     
                                    <telerik:GridNumericColumn DataField="Qty_remaining" HeaderText="Qty Remaining" DecimalDigits="0" ReadOnly="true" UniqueName="Qty_remaining" Display="false">
                                    </telerik:GridNumericColumn>
 
                                    <telerik:GridBoundColumn DataField="MfgLotNo" HeaderText="Manufacturer Lot No" UniqueName="MfgLotNo">
                                    </telerik:GridBoundColumn>
 
                                    <telerik:GridBoundColumn DataField="Lot_no" HeaderText="Lot No" UniqueName="Lot_no" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                     
                                    <telerik:GridBoundColumn DataField="Loc" HeaderText="Location" UniqueName="Loc" ReadOnly="true" Display="false">
                                    </telerik:GridBoundColumn>   
                                                                      
                                    <%--<telerik:GridBoundColumn DataField="Bin" HeaderText ="PO_Bin_no" Visible="true" UniqueName="PO_Bin_no" ReadOnly="true" Display="false">
                                    </telerik:GridBoundColumn>--%>
 
                                    <telerik:GridTemplateColumn HeaderText="Bin #" UniqueName="Bin_no" DataField="Bin">
                                        <ItemTemplate>
                                            <%# Eval("Bin") %>                                 
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <%--<telerik:RadComboBox runat="server" ID="Bin_ComboBox1" EnableLoadOnDemand="true" DataTextField="Bin" DataValueField="Bin"
                                                 AutoPostBack="false" AllowCustomText="false" OnDataBound="Bin_ComboBox_DataBound"  >
                                            </telerik:RadComboBox>  --%>
                                             
                                            <telerik:RadDropDownList runat="server" ID="Bin_no1" AutoPostBack="false" DataTextField="Bin" DataValueField="Bin">
                                            </telerik:RadDropDownList>                                   
                                        </EditItemTemplate>
                                    </telerik:GridTemplateColumn>
                                     
                                    <%--<telerik:GridButtonColumn ConfirmText="Delete this Line?" ConfirmDialogType="RadWindow"
                                        ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton"
                                        CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" ImageUrl="Images/16x16_remove.png">
                                    </telerik:GridButtonColumn>--%>
                                    <telerik:GridButtonColumn ConfirmText="Delete this Line?" ConfirmDialogType="RadWindow"
                                        ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton"
                                        CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                    </telerik:GridButtonColumn>
                                </Columns>
 
                            </MasterTableView>
                            <ExportSettings ExportOnlyData="false" IgnorePaging="true" OpenInNewWindow="true">
                                <Csv EncloseDataWithQuotes="true" ColumnDelimiter="Comma" />
                                <Excel Format="Biff" />
                            </ExportSettings>
                            <ClientSettings AllowKeyboardNavigation="false" AllowColumnsReorder="false">
                                <ClientEvents
                                    OnBatchEditSetCellValue="CellValueChanged"
                                    OnBatchEditCellValueChanging="BatchEditCellValueChanging"                                                                    
                                    OnBatchEditOpened="BatchEditOpened"                                   
                                    OnBatchEditOpening="BatchEditOpening"
                                    OnBatchEditClosed="BatchEditClosed"
                                    OnRowDeleted="RowDeleted" />
                            </ClientSettings>
                        </telerik:RadGrid>
                        <br />
                        <telerik:RadButton ID="btnSubmitReceipt" runat="server" Text="Submit PO Receipt" OnClientClicked="saveEditRows"
                            ToolTip="Submit PO Receipt" AutoPostBack="false">
                        </telerik:RadButton>
 
<telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1"></telerik:RadAjaxLoadingPanel>
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" Skin="WebBlue" />
 
        <telerik:RadAjaxManager ID="RadAjaxManager1" EnableAJAX="true" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgPOLines" />
                        <telerik:AjaxUpdatedControl ControlID="rgMfgLot" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="rgMfgLot">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgMfgLot" />
                    </UpdatedControls>
                </telerik:AjaxSetting>                            
            </AjaxSettings>
       </telerik:RadAjaxManager>
 
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecorationZoneID="demo"
            DecoratedControls="All" EnableRoundedCorners="false" />

4 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 06 Oct 2015, 10:23 AM
Hello,

I am attaching a sample project with Batch Cell edit mode and advanced data binding that demonstrates the proper functionality of the DeleteCommand.
Test it on your end and see what the difference in your case is.

Regards,
Maria Ilieva
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
0
Tony
Top achievements
Rank 1
answered on 06 Oct 2015, 02:34 PM

Thanks, Maria.

 I looked over what you posted but I don't see where I am going wrong and why the delete command never gets fired. When I click on delete it never seems to actually postback at all.

 

Thanks,

Tony

0
Accepted
Maria Ilieva
Telerik team
answered on 07 Oct 2015, 12:23 PM
Hi,

Note that the server command will be executed after SaveChanges button is clicked. Give this a try and see if it works

Regards,
Maria Ilieva
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
0
Tony
Top achievements
Rank 1
answered on 07 Oct 2015, 06:33 PM

Thanks, Maria. That worked.

 I didn't realize I had to save the changes to get it to postback.

Tags
Grid
Asked by
Tony
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Tony
Top achievements
Rank 1
Share this question
or