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

RadGrid not refreshing

6 Answers 223 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 31 Jul 2008, 09:02 PM

Ok,

I have a grid I am updating from a RadWindow. The user clicks SAVE and the data is sent to the database. the window closes and calls the grid refresh method.

All works great. I look at the new data getting pulled during the NeedDataSource event and it is indeed correct.

However, the page never updates with the new data. The grid is defintely rebound, as the Item_Created event fires.. but why doesn't the grid show the refresh data? Am I missing something? Below is my code.

Thanks!

//ASPX PAGE
<
telerik:RadGrid ID="radData" runat="server" AutoGenerateColumns="False" AllowSorting="True" OnItemCreated="radData_ItemCreated" BorderStyle="None" Skin="Telerik" GridLines="None" OnNeedDataSource="radData_NeedDataSource" Width="985px" Height="800px">...

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">

//JAVASCRIPT
function ShowForm(site, form, rowIndex) {
if (form == 'refViewer') {
var grid = $find("<%= radData.ClientID %>");
var MasterTable = grid.get_masterTableView();
var row = MasterTable.get_dataItems()[rowIndex];
row.selected =
true;
}

window.radopen(site, form);

return false;
}

function refreshGrid(arg) {
$find(
"<%=RadAjaxManager1.ClientID%>").ajaxRequestWithTarget("<%=RadAjaxManager1.ClientID%>", "Rebind");
}
</script>
</
telerik:RadCodeBlock>

//CODE BEHIND....
protected void radData_NeedDataSource(object source, GridNeedDataSourceEventArgs e){
    bindData();

private

void bindData()
{
var ds = getDs();
dv =
new DataView {Table = ds.Tables[0]};

// grab some query strings for filtering
var clcFilter = Request.QueryString["clcfilter"];
var filter = Request.QueryString["filter"];
var bc = Request.QueryString["bc"];
var keyword = Request.QueryString["k"]; 

// if filter on, do some checks
if (filter != null)
    dv.RowFilter = getFilter(filter);
if (clcFilter != null)
    dv.RowFilter = bc !=
null ? getCLCFilter(clcFilter) : getCLCFilter(clcFilter);

// check for keyword search
if (!string.IsNullOrEmpty(keyword))
    dv.RowFilter = getSearch(keyword);

radData.DataSource = dv;
fillEntities();
}

protected void radData_ItemCreated(object sender, GridItemEventArgs e)
{
    if (!(e.Item is GridDataItem)) return;
    var dr = (DataRowView) e.Item.DataItem;
    var temp = dr["uniStatus"];
    var editLink = e.Item.FindControl("RefLink") as HyperLink;
     if (editLink == null) return;

    editLink.Text = dr[
"EntityName"].ToString();
    editLink.Attributes[
"href"] = "#";
    var site = "Ref.aspx?entityid=" + dr["EntityID"];
    editLink.Attributes[
"onclick"] = string.Format("return ShowForm('{0}','{1}', '{2}');", site,
    "refViewer", e.Item.ItemIndex);
}

Sean

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 01 Aug 2008, 05:11 AM
Hi Sean ,

Can you post the manager declaration also?

Kind regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Sean
Top achievements
Rank 2
answered on 01 Aug 2008, 01:53 PM

<

telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
<AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="radData">
            <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="radData" LoadingPanelID="RadAjaxLoadingPanel1" />
             </UpdatedControls>
         </telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>



Note that I have tried setting the AjaxControlID to the id of the radWindow as well, but the same effect.

Sean~

0
Sebastian
Telerik team
answered on 04 Aug 2008, 06:35 AM
Hi Sean ,

I reviewed your RadAjaxManager configuration and think that you need to add ajax setting in which the manager is set as initiator and the grid as an updated control as shown in this online demo:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Controls/Examples/Integration/GridAndWindow/DefaultCS.aspx?product=grid

You may also review the implementation from the relevent knowledge base article linked under the Description tab.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Sean
Top achievements
Rank 2
answered on 07 Aug 2008, 06:07 PM
I have set up everything exactly like the given project. The only difference is that I do not use a detailsview to wrap the contents. Because I am trying to quickly modify a very old app, I don't have time to re-tool the entire thing. I am just updating it to be used by a different team than originally written and wanted to incorporate Telerik controls. Eventually, if they continue to use it, I will be able to try it your way, but until then...


Instead of a details view, I load the page and have a RadToolBar as such:

    <telerik:RadToolbar ID="RadToolbar1" runat="server" style="z-index: 103;"     
 OnButtonClick="RadToolbar1_OnClick">    
    <Items>    
        <telerik:RadToolbarButton runat="server" Text="Save and Close" CommandName="Save"/>    
    </Items>    
</telerik:RadToolbar>   


here is the toolbar OnClick code:

 protected void RadToolbar1_OnClick(object sender, RadToolBarEventArgs e)  
        {  
            var button = e.Item as RadToolBarButton;  
 
            if (button != null)  
                switch (button.CommandName)  
                {  
                    case "Save":  
                        {  
                            UpdateData(...VALUES...);  
                            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);  
                            break;  
                        }  
                }  
        } 


I want to reiterate: EVERYTHING works as planned. All methods are called, all data is updated in the database. The only thing not working is the actual grid refresh.

One thing: In the REBIND call by the AjaxManager, I noticed that the NeedDataSource is called, followed by the AjaxRebind... This rebound the RadGrid twise so I removed the radData.Rebind() call.

Anyway, what is most confusing is the fact that the data returned during rebinding is all correct. The only thing wrong is that the actual page is not refreshed... I have had to resort to a manual Response.Redirect call in the RadAjaxManager1_AjaxRequest.

VERY ugly and VERY baffling.

Sean
0
Accepted
Sebastian
Telerik team
answered on 08 Aug 2008, 06:47 AM

Hello Sean,

Can you please check whether adding the manager setting suggested in my previous post and registering the client script which rebinds the control in the following way:

RadAjaxManager1.ResponseScripts.Add("CloseAndRebind();");

produces the desired result? The sympthoms you explained lead me to the conclusion that the grid is not updated by the ajax manager (in this configuration) since the code logic is processed and executed as expected as you specified.

Best regards,

Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Sean
Top achievements
Rank 2
answered on 08 Aug 2008, 06:58 PM
Two days of stupidity...

Thanks for the patience, but my ROOT problem was that I had renamed the grid, but left the original name in the RadAjaxManager... dumb, dumb, dumb..

Sean

Edit: Dumb, dumb, dumb... just to ensure we all know I was dumb...:/
Tags
Grid
Asked by
Sean
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Sean
Top achievements
Rank 2
Sebastian
Telerik team
Share this question
or