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

RadGrid doesnot refresh afer Edit/Delete

11 Answers 416 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RB
Top achievements
Rank 1
RB asked on 19 Mar 2014, 10:45 PM
I am implementing http://demos.telerik.com/aspnet-ajax/input/examples/common/datagrid/defaultcs.aspx in my Radgrid. But after edit/delete, the radgrid doesnot refresh.
After Edit and Delete I tried a couple of things like:
this.Page.RegisterRequiresPostBack(this._RadGrid1) and this._RadGrid1.MasterTableView.Rebind(); and e.Item.OwnerTableView.Rebind but none works.
Interestingly after delete, the number of records in the pager section is updated. For instance from  204 items in 3 pages, it refreshes to  203 items in 3 pages. But the deleted record doesnot go until I reload or click on refresh.
The OnPrerender is as follows:
 protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(Page);
            ajaxManager.AjaxSettings.AddAjaxSetting(this._UpdatePanel, this._RadGrid1, this._RadLoadingPanel);          
        } 

Please let me know how to refresh it.

11 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 24 Mar 2014, 02:37 PM
Hi,

Try modifying the RadAjaxManager settings so that RadGrid is set to update itself like illustrated in the demo. If you are adding the settings programmatically the setting would look similar to the one below:

RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(Page);
ajaxManager.AjaxSettings.AddAjaxSetting(RadGrid1, RadGrid1);

Give this approach a try and see if the behavior changes.

In case the problem persists would you share your full markup with the related code-behind? This would allow us to try and replicate the issue locally and look for its cause.

Regards,
Viktor Tachev
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
RB
Top achievements
Rank 1
answered on 27 Mar 2014, 09:07 PM
Nope that did not work. Here is the complete code:
public class OrderRequestOrderEntrySystemListCtrl : WebControl, INamingContainer
{
 
    #region Fields
    private L3RadGridTitleBar _L3RadGridTitleBar;
    private Telerik.Web.UI.RadGrid _RadGrid1 = new  Telerik.Web.UI.RadGrid();
    private RadAjaxLoadingPanel _RadLoadingPanel = new RadAjaxLoadingPanel();
    private UpdatePanel _UpdatePanel = new UpdatePanel();
     
    private CatalogProductRegionOrderEntryItemTable _CatalogProductRegionOrderEntryItemTable =     new CatalogProductRegionOrderEntryItemTable();
    private AvrmQueueTypeTable _AvrmQueueTypeTable = new AvrmQueueTypeTable();
    private CatalogProductTable _CatalogProductTable = new CatalogProductTable();
    string[] UniqueName = new string[3] { "SourceSystemType", "AVRM", "AVRMZ"};
    string[] DBColName = new string[3] { "SourceSystemType", "AVRMQueue", "AVRMQueueZ"};
    string[] AddUniqueName = new string[2] { "Description", "SameRegion" };
    string[] AddDBColName = new string[2] { "Description", "IsAllRegionsTheSame" };
    #endregion
 
    #region Constructors
 
    public OrderRequestOrderEntrySystemListCtrl() { }
    #endregion
 
    #region Overrides
 
    protected override void OnInit(EventArgs e)
    {                
        this._RadLoadingPanel.ID = "_RadLoadingPanel";
        this._RadLoadingPanel.Transparency = 30;
        this._RadLoadingPanel.Skin = "WebBlue";
        this._RadLoadingPanel.BackgroundPosition = AjaxLoadingPanelBackgroundPosition.TopRight;
        this.Controls.Add(this._RadLoadingPanel);
 
        this._L3RadGridTitleBar = new L3RadGridTitleBar(_RadGrid1);
        this._L3RadGridTitleBar.ID = "_L3RadGridTitleBar";
        this._L3RadGridTitleBar.PageOrientation = Orientation.Vertical;
        this._L3RadGridTitleBar.CellAlignment = System.Drawing.ContentAlignment.MiddleLeft;
        this._L3RadGridTitleBar.ShowExportXls = true;
        this.Controls.Add(this._L3RadGridTitleBar);
     
        this._RadGrid1.Skin = "WebBlue";
        this._RadGrid1.Width = Unit.Percentage(98);
        this._RadGrid1.GridLines = GridLines.None;
        this._RadGrid1.PageSize = 100;
        this._RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
 
        this._RadGrid1.AllowPaging = true;
        this._RadGrid1.AllowSorting = true;
        this._RadGrid1.AllowFilteringByColumn = true;
        this._RadGrid1.AllowAutomaticDeletes = true;
        this._RadGrid1.AllowAutomaticInserts = true;
        this._RadGrid1.AllowAutomaticUpdates = true;  
        this._RadGrid1.AutoGenerateColumns = false;
        this._RadGrid1.AutoGenerateEditColumn = true;
        this._RadGrid1.AutoGenerateDeleteColumn = true;
        this._RadGrid1.ClientSettings.DataBinding.EnableCaching = true;
        this._RadGrid1.ClientSettings.AllowGroupExpandCollapse = true;       
      
        this._RadGrid1.ClientSettings.AllowKeyboardNavigation = true;
        
        this._RadGrid1.EnableGroupsExpandAll = true;
        this._RadGrid1.EnableLinqExpressions = false;
        this._RadGrid1.EnableHeaderContextFilterMenu = true;
        this._RadGrid1.GroupingEnabled = true;
        this._RadGrid1.ShowGroupPanel = true;
         
        this._RadGrid1.MasterTableView.GroupLoadMode = GridGroupLoadMode.Client;
        this._RadGrid1.MasterTableView.Width = Unit.Percentage(100);
        this._RadGrid1.MasterTableView.EnableHeaderContextMenu = true;
        this._RadGrid1.MasterTableView.EnableHeaderContextFilterMenu = true;
        this._RadGrid1.MasterTableView.NoMasterRecordsText = "There are no Order Entry System Settings";
        this._RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
        this._RadGrid1.MasterTableView.DataKeyNames = new string[] {this._CatalogProductRegionOrderEntryItemTable.CatalogProductRegionOrderEntryIdColumn.ColumnName};
        this._RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.TopAndBottom;
        this._RadGrid1.MasterTableView.CommandItemSettings.AddNewRecordText = "Add Order Entry Setting";
        this._RadGrid1.MasterTableView.InsertItemPageIndexAction = GridInsertItemPageIndexAction.ShowItemOnCurrentPage;
        this._RadGrid1.MasterTableView.EditMode = GridEditMode.InPlace;
 
        //this._RadGrid1.MasterTableView.DetailItemTemplate = new OrderRequestOESTemplate();
        this._RadGrid1.ItemCreated += RadGrid1_ItemCreated;         
        this._RadGrid1.ItemCommand += _RadGrid1_ItemCommand;
       // this._RadGrid1.EditCommand += _RadGrid1_EditCommand;
        this._RadGrid1.DeleteCommand += _RadGrid1_DeleteCommand;          
        this._RadGrid1.UpdateCommand += RadGrid1_UpdateCommand;
        this._RadGrid1.InsertCommand += _RadGrid1_InsertCommand;
 
        this._RadGrid1.NeedDataSource += RadGrid1_NeedDataSource;
 
        LoadList();
     
        #region Columns
        String columnName;
 
        columnName = this._CatalogProductRegionOrderEntryItemTable.DescriptionColumn.ColumnName;
        GridBoundColumn boundColumn = new GridBoundColumn();
        this._RadGrid1.MasterTableView.Columns.Add(boundColumn);
        boundColumn.FilterTemplate = new DropdownTemplate(columnName, _RadGrid1, this._CatalogProductTable.SelectDistinct(columnName));
        boundColumn.DataField = columnName;
        boundColumn.HeaderText = "Product";
        boundColumn.UniqueName = this._CatalogProductRegionOrderEntryItemTable.DescriptionColumn.ColumnName;
        boundColumn.Groupable = true;          
            
        columnName = this._CatalogProductRegionOrderEntryItemTable.SourceSystemTypeColumn.ColumnName;
        boundColumn = new GridBoundColumn();
        boundColumn.FilterTemplate = new DropdownTemplate(columnName, _RadGrid1, this._CatalogProductRegionOrderEntryItemTable.SelectDistinct(columnName));
        this._RadGrid1.MasterTableView.Columns.Add(boundColumn);
        boundColumn.DataField = columnName;
        boundColumn.AllowFiltering = true;
        boundColumn.Groupable = true;
        boundColumn.AutoPostBackOnFilter = true;
        boundColumn.HeaderText = "Order Entry System";
        boundColumn.UniqueName = columnName;
        boundColumn.AllowSorting = true;           
 
        boundColumn = new   GridBoundColumn();
        this._RadGrid1.MasterTableView.Columns.Add(boundColumn);
        boundColumn.DataField = this._CatalogProductRegionOrderEntryItemTable.IsALLRegionsTheSameColumn.ColumnName;
        boundColumn.HeaderText = "Same Region";
        boundColumn.AllowSorting = true;
        boundColumn.Groupable = true;
        boundColumn.UniqueName = "SameRegion";                    
 
        columnName = this._CatalogProductRegionOrderEntryItemTable.AVRMQueueColumn.ColumnName; ;
        boundColumn = new GridBoundColumn();
        this._RadGrid1.MasterTableView.Columns.Add(boundColumn);
        boundColumn.FilterTemplate = new DropdownTemplate(columnName, this._RadGrid1, this._AvrmQueueTypeTable);
        boundColumn.DataField = columnName;
        boundColumn.HeaderText = "AVRM";
        boundColumn.AllowFiltering = true;
        boundColumn.Groupable = true;
        boundColumn.UniqueName = "AVRM";
 
        columnName = this._CatalogProductRegionOrderEntryItemTable.AvrmDisplayColumn.ColumnName;
        boundColumn = new GridBoundColumn();
        this._RadGrid1.MasterTableView.Columns.Add(boundColumn);           
        boundColumn.DataField = columnName;
        boundColumn.HeaderText = "AVRM Name";
        boundColumn.AllowFiltering = false;
        boundColumn.UniqueName = "AVRMName";          
         
        columnName = this._CatalogProductRegionOrderEntryItemTable.AVRMQueueZColumn.ColumnName;           
        boundColumn = new GridBoundColumn();
        this._RadGrid1.MasterTableView.Columns.Add(boundColumn);
        boundColumn.FilterTemplate = new DropdownTemplate(columnName, this._RadGrid1, this._CatalogProductRegionOrderEntryItemTable.SelectDistinct(columnName));
        boundColumn.DataField = columnName;
        boundColumn.HeaderText = "AVRM Z";
        boundColumn.AllowFiltering = true;
        boundColumn.Groupable = true;
        boundColumn.UniqueName = "AVRMZ";
 
        columnName = this._CatalogProductRegionOrderEntryItemTable.AvrmDisplayZColumn.ColumnName;
        boundColumn = new GridBoundColumn();
        this._RadGrid1.MasterTableView.Columns.Add(boundColumn);           
        boundColumn.DataField = columnName;
        boundColumn.HeaderText = "AVRM Z Name";
        boundColumn.AllowFiltering = false;
        boundColumn.UniqueName = "AVRMZName";
         
        #endregion
                        
        this._UpdatePanel.ID = "ajaxPanel";
        this._UpdatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
        this._UpdatePanel.ContentTemplateContainer.Controls.Add(this._RadGrid1);
 
        this.Controls.Add(this._UpdatePanel);
 
        base.OnInit(e);
    }
     
 
    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            this._RadGrid1.EditIndexes.Add(0);
        }
    }
 
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem item = e.Item as GridEditableItem;
            GridEditManager manager = item.EditManager;                                    
                          
            for (int count = 0; count < UniqueName.Length; count++)
            {
                TextBox txt = (TextBox)item[UniqueName[count]].Controls[0];
                txt.Visible = false;
 
                DropDownList droplist = new DropDownList();
                droplist.ID = "DropDownList" + UniqueName[count];
                droplist.DataSource = this._CatalogProductRegionOrderEntryItemTable.SelectDistinct(DBColName[count]);
                if (UniqueName[count].Equals("AVRM"))
                    droplist.DataSource = this._AvrmQueueTypeTable;
                droplist.DataTextField = DBColName[count];
                droplist.DataValueField = DBColName[count];
                droplist.DataBind();
                item[UniqueName[count]].Controls.Add(droplist);
            }
            //Adding columns that are not editable
            GridTextBoxColumnEditor editor = manager.GetColumnEditor("AVRMName") as GridTextBoxColumnEditor;
            editor.TextBoxControl.Enabled = false;
            editor.TextBoxControl.BackColor = System.Drawing.Color.Gray;
            editor.TextBoxControl.ForeColor = System.Drawing.Color.Black;
            editor = manager.GetColumnEditor("AVRMZName") as GridTextBoxColumnEditor;
            editor.TextBoxControl.Enabled = false;
            editor.TextBoxControl.BackColor = System.Drawing.Color.Gray;
            editor.TextBoxControl.ForeColor = System.Drawing.Color.Black;
 
            //if not insert
            if (!(e.Item is GridEditFormInsertItem) && e.Item.ItemIndex >= 0)
            {               
                //Adding columns that are not editable
                editor = manager.GetColumnEditor("Description") as GridTextBoxColumnEditor;
                editor.TextBoxControl.Enabled = false;
                editor.TextBoxControl.BackColor = System.Drawing.Color.Gray;
                editor.TextBoxControl.ForeColor = System.Drawing.Color.Black;
                editor = manager.GetColumnEditor("SameRegion") as GridTextBoxColumnEditor;
                editor.TextBoxControl.Enabled = false;
                editor.TextBoxControl.BackColor = System.Drawing.Color.Gray;
                editor.TextBoxControl.ForeColor = System.Drawing.Color.Black;                   
            }
            //if insert add Product and Region dropdown
            if (!(e.Item is GridEditFormInsertItem) && e.Item.ItemIndex < 0)
            {
                for (int count = 0; count < AddUniqueName.Length; count++)
                {
                    DropDownList droplist = new DropDownList();
                    droplist = new DropDownList();
                    droplist.ID = "DropDownList" + AddUniqueName[count];
                    TextBox txt = (TextBox)item[AddUniqueName[count]].Controls[0];
                    txt.Visible = false;
 
                    droplist.DataSource = this._CatalogProductRegionOrderEntryItemTable.SelectDistinct(AddDBColName[count]);
                    droplist.DataTextField = AddDBColName[count];
                    droplist.DataValueField = AddDBColName[count];
                    droplist.DataBind();
                    item[AddUniqueName[count]].Controls.Add(droplist);
                }
            }
        }
    }
             
    void _RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {          
        GridEditableItem editedItem = e.Item as GridEditableItem;
        DataTable ordersTable = this._CatalogProductRegionOrderEntryItemTable;
        DataRow newRow = ordersTable.NewRow();  
    }
 
    void _RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
    {
        String SourceSystemDescription = "", AVRMQ = "", AVRMZ = "", Product = "";
        bool IsAllRegionsTheSame = false;
        GridEditableItem editedItem = e.Item as GridEditableItem;
        //fetching the values selected
        for (int count = 0; count < UniqueName.Length; count++)
        {
            DropDownList drop = (DropDownList)editedItem.FindControl("DropDownList" + UniqueName[count]);
            if (UniqueName[count].Equals("SourceSystemType"))
                SourceSystemDescription = drop.SelectedValue;
            if (UniqueName[count].Equals("AVRM"))
                AVRMQ = drop.SelectedValue;
            if (UniqueName[count].Equals("AVRMZ"))
                AVRMZ = drop.SelectedValue;
        }
        for (int count = 0; count < AddUniqueName.Length; count++)
        {
            DropDownList drop = new DropDownList();
            drop= (DropDownList)editedItem.FindControl("DropDownList" + AddUniqueName[count]);
            if (AddUniqueName[count].Equals("Description"))
                Product = drop.SelectedValue;
            if (AddUniqueName[count].Equals("SameRegion"))
                IsAllRegionsTheSame = Convert.ToBoolean(drop.SelectedValue);
        }
                    
        CatalogProductRegionOrderEntry_Add _CatalogProductRegionOrderEntry_Add = new CatalogProductRegionOrderEntry_Add();
        _CatalogProductRegionOrderEntry_Add.ExecuteNonQuery(Product, SourceSystemDescription,IsAllRegionsTheSame, AVRMQ, AVRMZ);
        this._RadGrid1.MasterTableView.Rebind();                      
    }
    void _RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
    {
        CatalogProductRegionOrderEntry_DeleteById _CatalogProductRegionOrderEntry_DeleteById = new CatalogProductRegionOrderEntry_DeleteById();
        GridEditableItem editedItem = e.Item as GridEditableItem;
        int Id = 0;           
        // determine the ID
        Id = Convert.ToInt32(editedItem.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["CatalogProductRegionOrderEntryId"]);          
        _CatalogProductRegionOrderEntry_DeleteById.ExecuteNonQuery(Id);
        this._RadGrid1.MasterTableView.Rebind();
    }
             
    protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
    {
        String SourceSystemDescription = "", AVRMQ = "", AVRMZ = "";
        int CatalogProductRegionOEID;
        GridEditableItem editedItem = e.Item as GridEditableItem;
 
        for (int count = 0; count < UniqueName.Length; count++)
        {
            DropDownList drop = (DropDownList)editedItem.FindControl("DropDownList"+UniqueName[count]);
            if(UniqueName[count].Equals("SourceSystemType"))
                SourceSystemDescription = drop.SelectedValue;
            if (UniqueName[count].Equals("AVRM"))
                AVRMQ = drop.SelectedValue;
            if (UniqueName[count].Equals("AVRMZ"))
                AVRMZ = drop.SelectedValue;
        }
        // determine the ID
        CatalogProductRegionOEID = Convert.ToInt32(editedItem.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["CatalogProductRegionOrderEntryId"]);
              
        CatalogProductRegionOrderEntry_Update _CatalogProductRegionOrderEntryUpdate = new CatalogProductRegionOrderEntry_Update();
        _CatalogProductRegionOrderEntryUpdate.ExecuteNonQuery(SourceSystemDescription, AVRMQ, AVRMZ, CatalogProductRegionOEID);
                  
        this._RadGrid1.MasterTableView.Rebind();                      
    }
   
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(Page);
        ajaxManager.AjaxSettings.AddAjaxSetting(this._UpdatePanel, this._RadGrid1, this._RadLoadingPanel);         
    }
 
    #endregion Overrides
 
    #region Utility Methods
 
    void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        LoadList();
       this._RadGrid1.DataSource = this._CatalogProductRegionOrderEntryItemTable;
    }
 
    private void LoadList()
    {
        if (this._CatalogProductRegionOrderEntryItemTable.Count < 1)
            this._CatalogProductRegionOrderEntryItemTable = new CatalogProductRegionOrderEntry_List().ExecuteTypedDataTable();
        _AvrmQueueTypeTable = new AvrmQueue_List().ExecuteTypedDataTable();
        _CatalogProductTable = new CatalogProduct_List().ExecuteTypedDataTable();
    }
    #endregion Utility Methods 
}
0
RB
Top achievements
Rank 1
answered on 27 Mar 2014, 09:15 PM
Also I am unable to sort columns though I add the following on each column!
 boundColumn.AllowSorting = true; 
0
Princy
Top achievements
Rank 2
answered on 28 Mar 2014, 03:12 AM
Hi,

I think you are performing manual insert and update operations. Hence, you should not be setting the AllowAutomaticInserts/AllowAutomaticUpdates/AllowAutomaticDeletes to true which may cause issues in the CRUD operation. The automatic operations work only when binding the grid to a declarative data source using the DataSourceID property of the grid. So set those properties to false.
Then RadGrid automatically sort its columns by setting the AllowSorting property to True. Can you try setting the SortExpression property of your columns.
Please make these changes and let me know if any concern.

Thanks,
Princy

0
RB
Top achievements
Rank 1
answered on 28 Mar 2014, 03:51 PM
Nope. It did not work. Just boundcolumn.AllowSorting = true should so the trick? No need to handle the sort event?
0
RB
Top achievements
Rank 1
answered on 28 Mar 2014, 06:10 PM
The edit or insert area closes but doesnot refresh. Also sort doesnt work still.
0
Viktor Tachev
Telerik team
answered on 01 Apr 2014, 11:53 AM
Hello,

From the provided code it seems that you are adding columns to RadGrid using the Init event handler. Note that when columns are added to the grid on Page_Init you must add the columns to the corresponding TableView after their properties are set. Check this article that illustrates the approach.

Additionally if you would like more information on manually handling update, insert, and delete operations in RadGrid you would find this demo interesting.


Regards,
Viktor Tachev
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
RB
Top achievements
Rank 1
answered on 14 Apr 2014, 07:32 PM
Thanks for the reply Viktor. I am now adding columns after setting their properties. Still it fails to refresh after an Add/Update/Delete!    
0
Viktor Tachev
Telerik team
answered on 17 Apr 2014, 02:05 PM
Hi,

I am attaching a sample project illustrating the approach for creating RadGrid programmatically and handling the Update and Insert commands. The sample is working as expected on my end. Please try using similar approach and you should achieve the needed functionality.

Also note that you do not need to call Rebind() for the RadGrid in the Update, Delete or Insert handlers as these commands invoke Rebind() implicitly. If you would like additional information on the commands that invoke Rebind() it is available in this article.

Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Rajesh
Top achievements
Rank 1
answered on 13 Jun 2014, 08:41 PM
Hi Viktor Tachev,

In the RADGrid control the Filter and Pagination is not working in my machine and my colleagues machines it is working fine. The RadAjaxLoadingPanel is not working properly in my machine. I have also attached the source code for your reference. Please look into it.

Please let me know how to resolve this issue.
Thanks,
Rajesh

MedicareLookup.aspx
----------------------------------

<%@ Page Language="VB" MasterPageFile="~/MasterPages/Full.master" AutoEventWireup="false" CodeFile="MedicareLookup.aspx.vb" Inherits="admin_MedicareLookup" title="Medicare Lookup" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMeta" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphIncludes" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphMain" Runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="cphSectionName" Runat="Server">
    Medicare Lookup 
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="cphSection" Runat="Server">   
    <telerik:RadCodeBlock ID="rgcbMedicareLookup" runat="server">
        <script type="text/javascript">
            var activeCommandButton;

            function confirmAndFireItemCommand(customTitle, button) {
                activeCommandButton = button;
                return radconfirm(customTitle, confirmCallBackFn, 400, 200, customTitle);
            }

            function confirmCallBackFn(arg, button) {
                var masterTable = $find("<%= rgrdMedicareLookup.ClientID%>").get_masterTableView();
                masterTable.fireCommand("Copy", arg);
            }
            function RowSelected(sender, args) {
                alert("test");
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadGrid ID="rgrdMedicareLookup" CssClass="Announcements GridInContent" runat="server" AllowPaging="True" AutoGenerateColumns="False" 
        GridLines="None" Skin="Default" PageSize="25" AllowFilteringByColumn="True" AllowMultiRowSelection="True" SelectedItemStyle-ForeColor="#FF0000" SelectedItemStyle-BackColor="#999999">
                <ClientSettings Selecting-AllowRowSelect="true">
                    <ClientEvents OnColumnClick="RowSelected" OnRowSelected="RowSelected" OnRowDeselected="RowDeselected" />
         </ClientSettings>
        <GroupingSettings CaseSensitive="false" />
        <HeaderContextMenu Skin="Default" EnableTheming="True">
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
        </HeaderContextMenu>
        <PagerStyle Mode="NextPrevNumericAndAdvanced" />
        <MasterTableView DataKeyNames="LookupLetterID" AllowSorting="True" NoDetailRecordsText="" NoMasterRecordsText="No Letter Templates" CommandItemDisplay="Bottom">
            <CommandItemTemplate>
                <table>
                    <tr>
                        <td align="left" style="padding:5px;">
                            <asp:Button ID="btnNew" runat="server" CommandName="Create" CssClass="linkButton" Text="Create" Height="25px" Width="100px" /> 
                            &nbsp; 
                            <asp:Button ID="btnCopy" runat="server" CommandName="Copy" CssClass="linkButton" Text="Copy" Height="25px" Width="100px" OnClientClick="javascript: if (confirmAndFireItemCommand('Will this new lookup record be replacing the selected record?', this)) { return true; } else { return false; }" />
                            &nbsp;
                            <asp:Button ID="btnApprove" runat="server" CommandName="Approve" CssClass="linkButton" Text="Approve" Height="25px" Width="100px" />
                            &nbsp;
                            <asp:Button ID="btnDeactivate" runat="server" CommandName="Deactivate" CssClass="linkButton" Text="Deactivate" Height="25px" Width="150px" />
                        </td>
                        <td align="right" style="padding:5px;">
                            <asp:Button ID="btnRefresh" runat="server" CommandName="Rebind" CssClass="linkButton" Text="Refresh" Height="25px" Width="100px" />
                        </td>
                    </tr>
                </table>
            </CommandItemTemplate>                       
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
             <Columns>
                <telerik:GridClientSelectColumn    
                    UniqueName="SelectOrder" >
                </telerik:GridClientSelectColumn>
                <telerik:GridBoundColumn DataField="LookupLetterID" UniqueName="LookupLetterID" HeaderText="LookupLetterID" DataType="System.Int32" Display="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LookupLetterFamilyID" UniqueName="LookupLetterFamilyID" HeaderText="LookupLetterFamilyID" DataType="System.Int32" Display="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CarrierID" UniqueName="CarrierID" HeaderText="CarrierID" DataType="System.String" AllowFiltering="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PBPID" UniqueName="PBPID" HeaderText="PBPID" DataType="System.String" AllowFiltering="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LanguageIndicator" UniqueName="LanguageIndicator" HeaderText="Language" DataType="System.String">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Status" UniqueName="Status" HeaderText="Status" DataType="System.String" AllowFiltering="true">
                </telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataField="EffectiveDate" UniqueName="EffectiveDate" HeaderText="Effective Date" DataType="System.DateTime" ItemStyle-Width="130px">
                </telerik:GridDateTimeColumn>
                <telerik:GridDateTimeColumn DataField="ArchiveDate" UniqueName="ArchiveDate" HeaderText="Archive Date" ItemStyle-Width="130px" DataType="System.DateTime">
                </telerik:GridDateTimeColumn>

                <telerik:GridHyperLinkColumn AllowFiltering="False" AllowSorting="False" UniqueName="MedicareLookupDetailsLink" DataNavigateUrlFields="MedicareLookupDetailsLink" Text="View/Edit" ItemStyle-CssClass="linkButton">                    
                </telerik:GridHyperLinkColumn>
                <telerik:GridHyperLinkColumn AllowFiltering="False" AllowSorting="False" DataNavigateUrlFields="HistoryLink" Text="History" UniqueName="HistoryLink" ItemStyle-CssClass="linkButton">
                </telerik:GridHyperLinkColumn>
                <telerik:GridHyperLinkColumn AllowFiltering="False" AllowSorting="False" DataNavigateUrlFields="ProofLink" Text="Proof" UniqueName="ProofLink" ItemStyle-CssClass="linkButton" Display="false" >
                </telerik:GridHyperLinkColumn>

            </Columns>
            <EditFormSettings EditFormType="Template">
                <EditColumn UniqueName="EditCommandColumn1">
                </EditColumn>
                <FormTemplate>
                </FormTemplate>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableTheming="True">
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
        </FilterMenu>
    </telerik:RadGrid>
    
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel" runat="server" BackColor="White"
        Height="75px" Width="75px" Transparency="25">
        <div style="margin-top: 20px;">
            <img alt="Loading..." src='<%= Request.ApplicationPath %>/img/loader.gif' style="border: 0;" /><br />
            <span style="color: #561714; font-size: 18px; font-weight: bold; display: block;
                margin-top: 10px;">Loading</span>
        </div>
    </telerik:RadAjaxLoadingPanel>
    
    <telerik:RadAjaxManager ID="ramMedicareLookup" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgrdMedicareLookup">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgrdMedicareLookup" LoadingPanelID="RadAjaxLoadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    
    <telerik:RadWindowManager ID="rwmMedicareLookup" runat="server" Skin="Default">
    </telerik:RadWindowManager>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="cphPageFooter" Runat="Server">
</asp:Content>

<%@ Page Language="VB" MasterPageFile="~/MasterPages/Full.master" AutoEventWireup="false" CodeFile="MedicareLookup.aspx.vb" Inherits="admin_MedicareLookup" title="Medicare Lookup" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMeta" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphIncludes" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphMain" Runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="cphSectionName" Runat="Server">
    Medicare Lookup 
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="cphSection" Runat="Server">   
    <telerik:RadCodeBlock ID="rgcbMedicareLookup" runat="server">
        <script type="text/javascript">
            var activeCommandButton;

            function confirmAndFireItemCommand(customTitle, button) {
                activeCommandButton = button;
                return radconfirm(customTitle, confirmCallBackFn, 400, 200, customTitle);
            }

            function confirmCallBackFn(arg, button) {
                var masterTable = $find("<%= rgrdMedicareLookup.ClientID%>").get_masterTableView();
                masterTable.fireCommand("Copy", arg);
            }
            function RowSelected(sender, args) {
                alert("test");
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadGrid ID="rgrdMedicareLookup" CssClass="Announcements GridInContent" runat="server" AllowPaging="True" AutoGenerateColumns="False" 
        GridLines="None" Skin="Default" PageSize="25" AllowFilteringByColumn="True" AllowMultiRowSelection="True" SelectedItemStyle-ForeColor="#FF0000" SelectedItemStyle-BackColor="#999999">
                <ClientSettings Selecting-AllowRowSelect="true">
                    <ClientEvents OnColumnClick="RowSelected" OnRowSelected="RowSelected" OnRowDeselected="RowDeselected" />
         </ClientSettings>
        <GroupingSettings CaseSensitive="false" />
        <HeaderContextMenu Skin="Default" EnableTheming="True">
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
        </HeaderContextMenu>
        <PagerStyle Mode="NextPrevNumericAndAdvanced" />
        <MasterTableView DataKeyNames="LookupLetterID" AllowSorting="True" NoDetailRecordsText="" NoMasterRecordsText="No Letter Templates" CommandItemDisplay="Bottom">
            <CommandItemTemplate>
                <table>
                    <tr>
                        <td align="left" style="padding:5px;">
                            <asp:Button ID="btnNew" runat="server" CommandName="Create" CssClass="linkButton" Text="Create" Height="25px" Width="100px" /> 
                            &nbsp; 
                            <asp:Button ID="btnCopy" runat="server" CommandName="Copy" CssClass="linkButton" Text="Copy" Height="25px" Width="100px" OnClientClick="javascript: if (confirmAndFireItemCommand('Will this new lookup record be replacing the selected record?', this)) { return true; } else { return false; }" />
                            &nbsp;
                            <asp:Button ID="btnApprove" runat="server" CommandName="Approve" CssClass="linkButton" Text="Approve" Height="25px" Width="100px" />
                            &nbsp;
                            <asp:Button ID="btnDeactivate" runat="server" CommandName="Deactivate" CssClass="linkButton" Text="Deactivate" Height="25px" Width="150px" />
                        </td>
                        <td align="right" style="padding:5px;">
                            <asp:Button ID="btnRefresh" runat="server" CommandName="Rebind" CssClass="linkButton" Text="Refresh" Height="25px" Width="100px" />
                        </td>
                    </tr>
                </table>
            </CommandItemTemplate>                       
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
             <Columns>
                <telerik:GridClientSelectColumn    
                    UniqueName="SelectOrder" >
                </telerik:GridClientSelectColumn>
                <telerik:GridBoundColumn DataField="LookupLetterID" UniqueName="LookupLetterID" HeaderText="LookupLetterID" DataType="System.Int32" Display="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LookupLetterFamilyID" UniqueName="LookupLetterFamilyID" HeaderText="LookupLetterFamilyID" DataType="System.Int32" Display="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CarrierID" UniqueName="CarrierID" HeaderText="CarrierID" DataType="System.String" AllowFiltering="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PBPID" UniqueName="PBPID" HeaderText="PBPID" DataType="System.String" AllowFiltering="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LanguageIndicator" UniqueName="LanguageIndicator" HeaderText="Language" DataType="System.String">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Status" UniqueName="Status" HeaderText="Status" DataType="System.String" AllowFiltering="true">
                </telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataField="EffectiveDate" UniqueName="EffectiveDate" HeaderText="Effective Date" DataType="System.DateTime" ItemStyle-Width="130px">
                </telerik:GridDateTimeColumn>
                <telerik:GridDateTimeColumn DataField="ArchiveDate" UniqueName="ArchiveDate" HeaderText="Archive Date" ItemStyle-Width="130px" DataType="System.DateTime">
                </telerik:GridDateTimeColumn>

                <telerik:GridHyperLinkColumn AllowFiltering="False" AllowSorting="False" UniqueName="MedicareLookupDetailsLink" DataNavigateUrlFields="MedicareLookupDetailsLink" Text="View/Edit" ItemStyle-CssClass="linkButton">                    
                </telerik:GridHyperLinkColumn>
                <telerik:GridHyperLinkColumn AllowFiltering="False" AllowSorting="False" DataNavigateUrlFields="HistoryLink" Text="History" UniqueName="HistoryLink" ItemStyle-CssClass="linkButton">
                </telerik:GridHyperLinkColumn>
                <telerik:GridHyperLinkColumn AllowFiltering="False" AllowSorting="False" DataNavigateUrlFields="ProofLink" Text="Proof" UniqueName="ProofLink" ItemStyle-CssClass="linkButton" Display="false" >
                </telerik:GridHyperLinkColumn>

            </Columns>
            <EditFormSettings EditFormType="Template">
                <EditColumn UniqueName="EditCommandColumn1">
                </EditColumn>
                <FormTemplate>
                </FormTemplate>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableTheming="True">
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
        </FilterMenu>
    </telerik:RadGrid>
    
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel" runat="server" BackColor="White"
        Height="75px" Width="75px" Transparency="25">
        <div style="margin-top: 20px;">
            <img alt="Loading..." src='<%= Request.ApplicationPath %>/img/loader.gif' style="border: 0;" /><br />
            <span style="color: #561714; font-size: 18px; font-weight: bold; display: block;
                margin-top: 10px;">Loading</span>
        </div>
    </telerik:RadAjaxLoadingPanel>
    
    <telerik:RadAjaxManager ID="ramMedicareLookup" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgrdMedicareLookup">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgrdMedicareLookup" LoadingPanelID="RadAjaxLoadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    
    <telerik:RadWindowManager ID="rwmMedicareLookup" runat="server" Skin="Default">
    </telerik:RadWindowManager>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="cphPageFooter" Runat="Server">
</asp:Content>
MedicareLookup.aspx.vb
-----------------------------------
Imports System.Data
Imports Telerik.Web.UI
Imports System.Web.Services


Partial Class admin_MedicareLookup
    Inherits Objects.BasePage

    Private oDB As JNL.SuperFulfillment.DataBase = New JNL.SuperFulfillment.DataBase()

    Private m_bCanModify As Boolean = False

    Protected Sub Page_Load_Local(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Me.rgrdMedicareLookup.ClientSettings.Selecting.AllowRowSelect = True
            CheckPagePermission("ManageContents.View")
            m_bCanModify = objUserSession.HasPermission("ManageContents.Modify")
            ramMedicareLookup = RadAjaxManager.GetCurrent(Page)
            ramMedicareLookup.AjaxSettings.AddAjaxSetting(rgrdMedicareLookup, rgrdMedicareLookup)
        End If
    End Sub

    Protected Sub rgrdMedicareLookup_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgrdMedicareLookup.ItemDataBound
        If e.Item.ItemType = GridItemType.Item Or e.Item.ItemType = GridItemType.AlternatingItem Then
            Dim item As GridDataItem = CType(e.Item, GridDataItem)
            Dim cbSelect As CheckBox = CType(item("SelectOrder").Controls(0), CheckBox)
            If item.Item("Status").Text.ToUpper = "INACTIVE" Then
                cbSelect.Enabled = False
                item.SelectableMode = GridItemSelectableMode.None
            Else
                item.SelectableMode = GridItemSelectableMode.ServerAndClientSide
                cbSelect.Enabled = True
            End If
        End If
    End Sub

    Protected Sub rgrdMedicareLookup_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgrdMedicareLookup.NeedDataSource
        Try
            oDB.AddParameter("@UserID", objUserSession.UserID)
            Me.rgrdMedicareLookup.DataSource = oDB.ExecStoreProcDataTable("DataFeed.usp_Medicare_Lookup_Letter_Select")
        Catch ex As Exception
            log.Error(ex.Message.ToString)
        End Try
    End Sub


    Protected Sub rgrdMedicareLookup_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgrdMedicareLookup.ItemCommand

        If e.CommandName.Trim = "Create" Then
            Response.Redirect("~/Admin/Contents/MedicareLookupDetails.aspx")
        ElseIf e.CommandName.Trim = "Copy" Then
            Dim bNeedRebind As Boolean
            For Each dataItem As GridDataItem In rgrdMedicareLookup.MasterTableView.Items
                If TryCast(dataItem("SelectOrder").Controls(0), CheckBox).Checked Then
                    If dataItem.Item("Status").Text = "ACTIVE" Then
                        Dim bResponse As Boolean = CType(e.CommandArgument.ToString, Boolean)
                        UpdateLetterTemplate(e.CommandName.ToUpper, CType(dataItem.Item("LookupLetterID").Text, Long), CType(dataItem.Item("LookupLetterFamilyID").Text, Long), bResponse)
                        bNeedRebind = True
                    Else
                        log.Info("Unable to create a copy of LookupLetterID: " & dataItem.Item("LookupLetterID").Text & " because it's not in the ACTIVE status.")
                    End If
                End If
            Next
            If bNeedRebind Then
                rgrdMedicareLookup.Rebind()
            End If
        ElseIf e.CommandName.Trim = "Approve" Then
            Dim bNeedRebind As Boolean
            For Each dataItem As GridDataItem In rgrdMedicareLookup.MasterTableView.Items
                If TryCast(dataItem("SelectOrder").Controls(0), CheckBox).Checked Then
                    If dataItem.Item("Status").Text = "PROOF" Then
                        UpdateLetterTemplate(e.CommandName.ToUpper, CType(dataItem.Item("LookupLetterID").Text, Long), CType(dataItem.Item("LookupLetterFamilyID").Text, Long))
                        SiteHistoryInsert(SiteHistoryTypes.Misc, CType(dataItem.Item("LookupLetterID").Text, Long), "Status changed from '" & dataItem.Item("Status").Text & "' to 'APPROVED'", objUserSession.UserID, "Medicare_Letter_Lookpup")
                        bNeedRebind = True
                    Else
                        log.Info("Unable to approve LookupLetterID: " & dataItem.Item("LookupLetterID").Text & " because it's not in the PROOF status.")
                    End If
                End If
            Next
            If bNeedRebind Then
                rgrdMedicareLookup.Rebind()
            End If
        ElseIf e.CommandName.Trim = "Deactivate" Then
            Dim bNeedRebind As Boolean
            For Each dataItem As GridDataItem In rgrdMedicareLookup.MasterTableView.Items
                If TryCast(dataItem("SelectOrder").Controls(0), CheckBox).Checked Then
                    UpdateLetterTemplate(e.CommandName.ToUpper, CType(dataItem.Item("LookupLetterID").Text, Long), CType(dataItem.Item("LookupLetterFamilyID").Text, Long))
                    SiteHistoryInsert(SiteHistoryTypes.Misc, CType(dataItem.Item("LookupLetterID").Text, Long), "Status changed from '" & dataItem.Item("Status").Text & "' to 'INACTIVE'", objUserSession.UserID, "Medicare_Letter_Lookpup")
                    bNeedRebind = True
                End If
            Next
            If bNeedRebind Then
                rgrdMedicareLookup.Rebind()
            End If
        ElseIf e.CommandName.Trim = "Rebind" Then
            rgrdMedicareLookup.Rebind()
        End If

    End Sub


    Private Sub UpdateLetterTemplate(ByVal Action As String, ByVal LookupLetterID As Long, ByVal LookupLetterFamilyID As Long, Optional CopyConfirmResponse As Boolean = False)
        Try
            oDB.AddParameter("@Action", Action.ToString)
            oDB.AddParameter("@LookupLetterID", LookupLetterID)
            oDB.AddParameter("@LookupLetterFamilyID", LookupLetterFamilyID)
            oDB.AddParameter("@ModUserID", objUserSession.UserID)
            If Action.ToLower = "copy" Then
                oDB.AddParameter("@CopyConfirmResponse", CopyConfirmResponse)
            End If
            oDB.ExecStoreProcNonQuery("DataFeed.usp_Medicare_Lookup_Letter_Insert")
        Catch ex As Exception
            log.Error("Unable to " & Action.ToString & " LookupLetterID: " & LookupLetterID.ToString & ". Error:" & ex.Message.ToString)
        End Try
    End Sub


End Class









0
Viktor Tachev
Telerik team
answered on 18 Jun 2014, 11:42 AM
Hi Rajesh,

I used the provided code and tried to replicate the issue locally, however I am afraid that I was not able to. I used dummy data to bind the RadGrid and stripped some of the code in order to run the project. The paging and filtering seem to work as expected on my end. I made a short video as reference. Also the sample project I used for testing is attached to this post.

I also noticed that the AjaxSettings for RadAjaxManager were defined in both the markup and in the code-behind. You should use only one of the approaches - the one that is more convenient to you. Please note that when adding AjaxSettings programmatically you should use the approach illustrated in this article.

This being said, would you describe what is not working on your end. Is there an error thrown? Would you try and disable Ajax by setting the EnableAjax property to false and see if the issue will persist?


Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
RB
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
RB
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Rajesh
Top achievements
Rank 1
Share this question
or