关闭radwindow后网格刷新的问题

时间:2011-07-27 04:33:32

标签: c# asp.net telerik telerik-grid radwindow

我有radgrid刷新的问题,当我关闭popuup radwindow时,任何人都可以帮助找出问题。

我的Gridpage aspx代码如下所示

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" EnableAJAX="true">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True"
            GridLines="None" ShowGroupPanel="True" Skin="Black" AutoGenerateColumns="False" Width="100%" AllowAutomaticInserts="false" AllowAutomaticUpdates="false">
            <ClientSettings AllowDragToGroup="True" AllowColumnsReorder="True" ReorderColumnsOnClient="True">
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                <ClientEvents OnGridCreated="OnGridCreated" />
            </ClientSettings>

.......................
..................
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true"
            Skin="Black">
            <Windows>
                <telerik:RadWindow ID="UserListDialog" runat="server" Height="620px" Width="620px"
                    Left="150px" Top="50px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true"
                    OnClientClose="closeRadWindow" />
            </Windows>
        </telerik:RadWindowManager>

protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
        {
            if (e.Argument == "Rebind")
            {
                RadGrid1.MasterTableView.SortExpressions.Clear();
                RadGrid1.MasterTableView.GroupByExpressions.Clear();
                Presenter List = new Presenter(this);
                IList<FileAdmin> GridDta = List.PopulateGrid();
                RadGrid1.DataSource = GridDta;
                RadGrid1.Rebind();
            }
My javascript looks like this
function closeRadWindow()
                 {
                     $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");

                }
       function refreshGrid()
                 {
                   $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");

                 }

RadWindow aspx代码看起来像这样 的JavaScript

function CloseAndRebind() {
                        GetRadWindow().BrowserWindow.refreshGrid();
                        //GetRadWindow().close();
                    }
function GetRadWindow()
                     {
                        var oWindow = null;
                        if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)
                        return oWindow;
                    }

Radwindow aspx.cs文件看起来像这样

protected void buttonclick(object sender, EventArgs e)
{
if (result == true)
 {
ClientScript.RegisterStartupScript(Page.GetType(), "mykey1", "CloseAndRebind();", true);
 }
} 

2 个答案:

答案 0 :(得分:2)

修改JavaScript closeRadWindow方法,如提及bellow

function closeRadWindow(oWnd, eventArgs){

     var grid= $find("<%= RadGrid1.ClientID %>").get_masterTableView();
     grid.rebind();
}

答案 1 :(得分:1)

我使用的方法与tHARA_sOFT使用的方法非常相似......

    function refreshGrid(arg) {
      var grid = $find("<%= grdResults.ClientID %>").get_masterTableView();
      if (!arg) { //If we have arguments, then we need to jump to the page we were on
        grid.CurrentPageIndex = grid.PageCount - 1
      }
      grid.rebind();
    }

这让Rebind和RebindAndNavigate合二为一。所有基于Javascript的...

相关问题