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

Popup edit form not closing

1 Answer 241 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lev
Top achievements
Rank 1
Iron
Lev asked on 25 Jan 2019, 05:54 AM

     Hi, I am having strange behavior. When grid displays edit popup window and only one numeric field is changed Ok button closes the window. But if before changing the value of the box, I change different item from dropdown, database is updated but window stays open.

<telerik:RadGrid runat="server" ID="gvBudget" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True" Skin="Office2010Blue" AutoGenerateColumns="False"
    OnNeedDataSource="gvBudget_NeedDataSource" OnInsertCommand="gvBudget_InsertCommand" OnUpdateCommand="gvBudget_UpdateCommand" OnDeleteCommand="gvBudget_DeleteCommand"
    OnItemDataBound="gvBudget_ItemDataBound" OnItemCommand="gvBudget_ItemCommand" OnBatchEditCommand="gvBudget_BatchEditCommand"
    ShowGroupPanel="true" ShowFooter="true">
    <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
    <GroupingSettings CaseSensitive="false" ShowUnGroupButton="true" />
    <ClientSettings ReorderColumnsOnClient="true" AllowDragToGroup="true">
        <%--<Scrolling AllowScroll="True" UseStaticHeaders="True" />--%>
    </ClientSettings>
    <MasterTableView DataKeyNames="ItemID" ShowFooter="false" CommandItemDisplay="Top" PageSize="20" EditMode="PopUp"
        ItemStyle-HorizontalAlign="Left" AlternatingItemStyle-HorizontalAlign="Left" AllowFilteringByColumn="true"
        AllowMultiColumnSorting="true" ShowGroupFooter="true">
        <AlternatingItemStyle BackColor="AliceBlue" BorderColor="Red" />
        <BatchEditingSettings EditType="Cell"></BatchEditingSettings>
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <SelectFields>
                    <telerik:GridGroupByField FieldAlias="TeamName" FieldName="TeamName" />
                    <telerik:GridGroupByField FieldAlias="BudgetType" FieldName="BudgetTypeDescription" />
                    <telerik:GridGroupByField FieldAlias="YearlyBudget" FieldName="YearlyBudget" Aggregate="Sum" HeaderText="Total" FormatString="{0:C}" />
                </SelectFields>
                <GroupByFields>
                    <telerik:GridGroupByField FieldName="TeamName" FieldAlias="teamName" />
                </GroupByFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
        <Columns>
            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="editColumn"  ItemStyle-Width="30px">
                <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
            </telerik:GridEditCommandColumn>
<EditFormSettings InsertCaption="Add New Budget Item" CaptionFormatString="Edit Budget Item: {0}" CaptionDataField="BudgetTypeDescription" EditFormType="WebUserControl">
    <PopUpSettings Modal="True"></PopUpSettings>
</EditFormSettings>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CCBABudgetCtrlUpdate.ascx.cs" Inherits="ReportDriver.Controls.CCBABudgetCtrlUpdate" %>
<div class="grid_4 alpha">
    <div class="dockContent">
        <label>Year:</label>
        <div class="float-right">
            <telerik:RadNumericTextBox runat="server" ID="txtCurYear" ReadOnly="True" Enabled="False" Width="100px">
                <NumberFormat GroupSeparator="" DecimalDigits="0" />
            </telerik:RadNumericTextBox>
        </div>
    </div>
    <div class="dockContent">
        <label>Provider:</label>
        <div class="float-right">
            <telerik:RadComboBox runat="server" ID="ddlDoctor" DataSource='<%#CrossCurrent.Components.DoctorController.GetAllDoctors() %>' DataValueField="DoctorID" DataTextField="FullName" SelectedValue='<%# Bind("DoctorID")%>'
                EmptyMessage="Select Doctor/Facility" MarkFirstMatch="True" Width="280px" AutoPostBack="True" OnSelectedIndexChanged="ddlDoctor_OnSelectedIndexChanged">                                       
            </telerik:RadComboBox>
        </div>
    </div>
    <div class="dockContent">
        <label>Budget Type:</label>
        <div class="float-right">
            <telerik:RadComboBox runat="server" ID="ddlBudgetType" DataValueField="BudgetTypeID" DataTextField="BudgetTypeDescription"
                EmptyMessage="Select Budget Type" MarkFirstMatch="True" Width="280px" AutoPostBack="True" OnSelectedIndexChanged="ddlBudgetType_OnSelectedIndexChanged">                                       
            </telerik:RadComboBox>
        </div>
    </div>
    <div class="dockContent">
        <label>Annual Budget:</label>
        <div class="float-right">
            <telerik:RadNumericTextBox runat="server" ID="txtBudgetAmount" MinValue="0" EmptyMessage="Budget" Type="Currency" DbValue='<%# Bind("YearlyBudget")%>'></telerik:RadNumericTextBox>
        </div>
    </div>
</div>
<div class="clear"></div>
<div class="float-right">
    <asp:Button runat="server" ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' CssClass="button"/>
    <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" CssClass="button"></asp:Button>
</div>

 

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 29 Jan 2019, 08:15 AM
Hello Lev,

The combo has its AutoPostBack property enabled but it does not actually initiate the Update or PerformInsert command. Therefore, you have couple of options to resolve this issue:

1. Remove the AutoPostBack property and the code-behind selection changed logic from the combo and using its client-side selection index changed event handler fire a grid command:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/gridtableview-object/methods/firecommand

2. Alternatively, you can keep the current logic and at the end of updating the database in the ddlDoctor_OnSelectedIndexChanged or ddlBudgetType_OnSelectedIndexChanged you can close the edit mode manually by clearing the EditIndexes collection and calling gvBudget.Rebind(). Alternatively, you can call the CancelAll command:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/control-lifecycle/command-reference-

Using FireCommandEvent method:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/control-lifecycle/how-to-fire-command-events

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Lev
Top achievements
Rank 1
Iron
Answers by
Eyup
Telerik team
Share this question
or