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

FormTemplate doesn't close upon cancel

2 Answers 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
antanse
Top achievements
Rank 1
antanse asked on 16 Dec 2008, 03:03 PM


<telerik:RadGrid ID="grdTrips" runat="server"  
            AutoGenerateColumns="False"  
            EnableEmbeddedSkins="false" 
            Skin="spa"  
            Width="940" 
            ImagesPath="~/App_Themes/aqua/Grid" 
            > 
            <MasterTableView DataKeyNames="ID" 
            AllowSorting="true" 
            AllowMultiColumnSorting="false" 
            ShowHeadersWhenNoRecords="true" 
            AllowNaturalSort="false" 
            AllowPaging="true" 
            PageSize="25" 
            > 
            <Columns> 
                <telerik:GridBoundColumn DataField="ID" ReadOnly="true" Display="false"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="VehicleId" ReadOnly="true" Display="false"></telerik:GridBoundColumn> 
                <telerik:GridTemplateColumn UniqueName="Mileage Date" HeaderText="Mileage Date"
                    <ItemTemplate> 
                        <asp:Label ID="lblMileageDate" runat="server" Text='<%# Eval("MileageDate") %>'></asp:Label> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridBoundColumn DataField="TripMiles" UniqueName="TripMileage" HeaderText="Trip Mileage" /> 
                <telerik:GridBoundColumn DataField="Description" UniqueName="Description" HeaderText="Description" /> 
                <telerik:GridTemplateColumn UniqueName="Date Stamp" HeaderText="Date Stamp"
                    <ItemTemplate> 
                        <asp:Label ID="lblDateStamp" runat="server" Text='<%# Eval("DateStamp") %>'></asp:Label> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                 
                <telerik:GridButtonColumn ButtonType="ImageButton" Visible="true" CommandName="Delete" HeaderText="Delete" ConfirmText="Are you sure you want to permanently delete this vehicle trip?" ImageUrl="~/common/images/grid/SmallDelete.png"
                    <ItemStyle HorizontalAlign="center" Width="30px" /> 
                </telerik:GridButtonColumn> 
                 
                <telerik:GridEditCommandColumn  UniqueName="EditCommandColumn"  HeaderText="Edit" ButtonType="ImageButton"  UpdateText="Upadate" CancelText="Cancel" EditImageUrl="~/common/images/grid/SmallEdit.gif"
                    <HeaderStyle Width="85px"></HeaderStyle> 
                </telerik:GridEditCommandColumn> 
            </Columns> 
            <EditFormSettings EditFormType="Template"  CaptionFormatString="Edit details for vehicle trip with ID {0}" CaptionDataField="ID"
                <FormTemplate> 
                    <table width="100%" cellpadding="0" cellspacing="0" border="0"
                        <tr> 
                        <td><asp:Label ID="lblVehicleTripEntryDate" runat="server" meta:resourcekey="lblVehicleTripDate"></asp:Label></td
                        <td><asp:Label ID="lblVehicleTripMileage" runat="server" meta:resourcekey="lblVehicleTripMileage"></asp:Label> 
                        </td> 
                         <td><asp:Label ID="lblVehicleTripDescription" runat="server" meta:resourcekey="lblVehicleTripDescription"></asp:Label></td
                <br /> 
            </tr> 
                        <tr> 
                <td> 
                    <telerik:RadDatePicker ID="dtpTDate" runat="server" 
                        MinDate="01/01/1980" 
                        DatePopupButton-Visible="true" 
                        DatePopupButton-ImageUrl="~/common/images/co/calendar/datePickerPopup.gif" 
                        DatePopupButton-HoverImageUrl="~/common/images/co/calendar/datePickerPopupHover.gif" 
                        DatePopupButton-CssClass="cssTelerikPopupImage" 
                        DatePopupButton-Width="21" 
                        DateInput-Width="50" 
                        EnableEmbeddedSkins="false" 
                        SelectedDate='<%# Bind("MileageDate") %>'  
                        Skin="spa" 
                        Width="120" 
                        > 
                            <Calendar ID="caldtTDate" runat="server" 
                                BackColor="#CDF4FE" 
                                EnableMultiSelect="false" 
                                FastNavigationNextImage="~/common/images/calendar/cal_nextMonthDouble.gif" 
                                FastNavigationPrevImage="~/common/images/calendar/cal_prevMonthDouble.gif" 
                                NavigationNextImage="~/common/images/calendar/cal_nextMonth.gif" 
                                NavigationPrevImage="~/common/images/calendar/cal_prevMonth.gif" 
                                ShowColumnHeaders="true" 
                                ShowRowHeaders="false" 
                                DefaultCellPadding="5" 
                                CalendarTableStyle-BorderWidth="1" 
                                CalendarTableStyle-BorderColor="#90CCF7" 
                                FastNavigationSettings-CancelButtonCaption="Cancel" 
                                FastNavigationSettings-EnableTodayButtonSelection="true" 
                                FastNavigationSettings-OkButtonCaption="Ok" 
                                FastNavigationSettings-TodayButtonCaption="Today" 
                                FastNavigationStyle-BackColor="#CDF4FE" 
                                FastNavigationStyle-BorderColor="#90CCF7" 
                                FastNavigationStyle-BorderWidth="2" 
                                EnableMonthYearFastNavigation="true" 
                                UseColumnHeadersAsSelectors="false" 
                                UseRowHeadersAsSelectors="false" 
                                > 
                            </Calendar> 
                        </telerik:RadDatePicker> 
                </td> 
                <td > 
                <telerik:RadTextBox ID="txtVehicleTripMileage"  
                        runat="server"  
                        EnableEmbeddedSkins="false"  
                        EmptyMessage="Required" 
                        SelectionOnFocus="CaretToBeginning" 
                        Skin="spa" 
                        MaxLength="100"  
                        Text='<%# Bind( "TripMiles") %>'     
                        Width="350" ValidationGroup="DataEntry" 
                        ></telerik:RadTextBox> 
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtVehicleTripMileage" Display="none" ValidationGroup="DataEntry"></asp:RequiredFieldValidator> 
                </td> 
                <td> 
                    <telerik:RadTextBox ID="txtDescription"  
                        runat="server"  
                        EnableEmbeddedSkins="false"  
                        EmptyMessage="Required" 
                        SelectionOnFocus="CaretToBeginning" 
                        Skin="spa" 
                        MaxLength="100"  
                        Text='<%# Bind( "Description") %>'     
                        Width="350" ValidationGroup="DataEntry" 
                        ></telerik:RadTextBox> 
                    <asp:RequiredFieldValidator ID="rfvDescription" runat="server" ControlToValidate="txtDescription" Display="none" ValidationGroup="DataEntry"></asp:RequiredFieldValidator> 
                </td> 
            </tr> 
            <tr> 
            <td colspan="3"
             <asp:Button ID="btnUpdate" Text="Update" runat="server" CommandName="Update"  CausesValidation="False"></asp:Button>&nbsp; 
             <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button> 
            </td> 
            </tr> 
                    </table> 
                </FormTemplate> 
            </EditFormSettings> 
            <NoRecordsTemplate> 
                <div style="border: solid 1px #666666; background-color: #eeeeee; color: #CE2020; width: 900px; margin-left: 20px; margin-right: 20px; margin-top: 20px; text-align: center; font-weight: bold; padding-top: 5px; padding-bottom: 5px;"
                    <table cellpadding="2" cellspacing="2"
                        <tr> 
                            <td><asp:image ID="imgNoRecords" runat="server" ImageUrl="~/common/images/icons/circle/RedX16.png" /></td
                            <td><span style=" font-size: 100%;">No records exist.</span></td
                        </tr> 
                    </table> 
                </div> 
            </NoRecordsTemplate> 
            </MasterTableView> 
            <ClientSettings EnableRowHoverStyle="true" /> 
</telerik:RadGrid> 

Hi everyone,
who can help me immediately? the above is my source code, however, when i click the 'cancel' button, formtemplate does not hide automatically?
Any ideas are appreciated
Albert

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Dec 2008, 05:29 AM
Hi Albert,

From the aspx provided above the edit form must close on clicking the Cancel button since you have set the CommandName as Cancel. You can also give a try the following code snippet in the ItemCommand event and see if it is working.

CS:
   protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "Cancel"
        { 
            RadGrid1.MasterTableView.ClearEditItems(); 
        } 
    } 


Shinu
0
Joel R
Top achievements
Rank 1
answered on 06 Jan 2009, 03:33 PM
it works... thanks
Tags
Grid
Asked by
antanse
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Joel R
Top achievements
Rank 1
Share this question
or