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

Refresh dont' work and delete don't refresh the grid

1 Answer 29 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hans van Rijnswoud
Top achievements
Rank 2
Hans van Rijnswoud asked on 15 Nov 2008, 06:45 PM
Hi,

I implemented a simple grid like your example : http://demos.telerik.com/ASPNET/prometheus/Grid/Examples/DataEditing/AllEditableColumns/DefaultCS.aspx

The problems are:
- When i click on the button refresh in the header of the grid, i can see the RadAjaxLoadingPanel but nothing append.
- When i click on the button delete, the row is deleted from my list of object but the grid is not refreshed.
Any idee of the problem?

Code aspx:
    <asp:Panel ID="PanelOverviewAddressType" runat="server" SkinID="PageContent"
               <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
                    <AjaxSettings> 
                        <telerik:AjaxSetting AjaxControlID="RadGrid1"
                             <UpdatedControls> 
                                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"/> 
                            </UpdatedControls> 
                        </telerik:AjaxSetting> 
                    </AjaxSettings> 
                </telerik:RadAjaxManager> 
                <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" Width="75px" Transparency="25"
                    <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' style="border:0;" /> 
                </telerik:RadAjaxLoadingPanel> 
                 
                 
                <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Vista" 
                GridLines="None" AllowPaging="True" AllowSorting="True" Width="100%" AutoGenerateColumns="False" 
                ShowStatusBar="false" OnPreRender="RadGrid1_PreRender" 
                       OnNeedDataSource="RadGrid1_NeedDataSource"  
                       OnUpdateCommand="RadGrid1_UpdateCommand"  
                       OnInsertCommand="RadGrid1_InsertCommand"  
                       OnDeleteCommand="RadGrid1_DeleteCommand"
                <MasterTableView GridLines="None" Width="100%" CommandItemDisplay="Top" DataKeyNames="AddressTypeId"
                    <RowIndicatorColumn> 
                        <HeaderStyle Width="20px" /> 
                    </RowIndicatorColumn> 
                    <ExpandCollapseColumn> 
                        <HeaderStyle Width="20px" /> 
                    </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridBoundColumn UniqueName="AddressTypeId" HeaderText="ID" DataField="AddressTypeId"
                        <HeaderStyle Width="20px" /> 
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn UniqueName="Name" HeaderText="Name" DataField="Name"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn UniqueName="CultureId" HeaderText="Ui Culture" DataField="CultureId" Visible="false"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn UniqueName="AddressTypeCultureName" HeaderText="Ui Culture" DataField="AddressTypeCultureName"
                    </telerik:GridBoundColumn> 
                    <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderText="Actions" ButtonType="ImageButton"
                    </telerik:GridEditCommandColumn> 
                    <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" ButtonType="ImageButton" ConfirmText="Do you want to delete this Address type?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete">  
                    </telerik:GridButtonColumn> 
                </Columns> 
                <EditFormSettings UserControlName="Views/CMSAddressTypeForm.ascx" EditFormType="WebUserControl"
                    <EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
                </EditFormSettings> 
            </MasterTableView> 
                    <FilterMenu EnableTheming="True" Skin="WebBlue"
                        <CollapseAnimation Duration="200" Type="OutQuint" /> 
                    </FilterMenu> 
        </telerik:RadGrid> 
         <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Vista"
        </telerik:RadWindowManager> 
            </asp:Panel> 


Code C#:

/// <summary> 
        /// Delete an AddressType 
        /// </summary> 
        /// <param name="sender">object</param> 
        /// <param name="e">GridItemEventArgs</param> 
        protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e) 
        { 
            var item = (GridDataItem)e.Item; 
            string addressTypeIdStr = item.OwnerTableView.DataKeyValues[item.ItemIndex]["AddressTypeId"].ToString(); 
            try 
            { 
                int _addressTypeId = int.Parse(addressTypeIdStr); 
                var _addressType = new AddressType(_addressTypeId); 
                if (ViewState["AddressTypeList"] != null
                { 
                    var _list = (List<AddressType>)ViewState["AddressTypeList"]; 
                    _list.Remove(_addressType); 
                    ViewState["AddressTypeList"] = _list; 
                } 
                _addressType.Delete(); 
            } 
            catch (Exception ex) 
            { 
                SetCanceled("Unable to delete this address type. Raison: " + ex.Message); 
                e.Canceled = true
            } 
        } 
 
 
/// <summary> 
        ///  
        /// </summary> 
        /// <param name="source">object</param> 
        /// <param name="ex">GridNeedDataSourceEventArgs</param> 
        protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs ex) 
        { 
            if (ViewState["AddressTypeList"] != null
            { 
                var _list = (List<AddressType>)ViewState["AddressTypeList"]; 
                RadGrid1.DataSource = _list; 
            } 
        } 







Extra question: how can i change the text of the button of a RadWindowManager?



Thanks.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 17 Nov 2008, 01:04 PM
Hello Edwin,

You can change the localization strings of the RadWindow control by using the following Javascript code that should be placed after the  RadWindowManager declaration:
Telerik.Web.UI.RadWindowUtils.Localization =    
{   
    "Close" : "Close",   
    "Minimize" : "Minimize",   
    "Maximize" : "Maximize",   
    "Reload" : "Reload",   
    "PinOn" : "Pin on",   
    "PinOff" : "Pin off",   
    "Restore" : "Restore",   
    "OK" : "OK",   
    "Cancel" : "Cancel",   
    "Yes" : "Yes",   
    "No" : "No"     
};  

Thanks
Princy.
Tags
Grid
Asked by
Hans van Rijnswoud
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 1
Share this question
or