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

How can I rebind my grid after a modal radwindow closes?

3 Answers 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Laura
Top achievements
Rank 1
Laura asked on 05 Nov 2008, 04:18 AM
I have a button outside my radgrid which when clicks, calls clientside javascript to open a modal radwindow and the window executes a wizard to create users for my grid. When the radwindow closes, I want the grid to rebind to show the new users. I have the window being created in the onclientclick event of the button. I also have an onclick server event handler for the button to rebind the grid, but it never gets executed. How can I rebind the grid after the window closes? I am attaching some code - hope it's enough....

aspx and Javascript:
   <div style="height:40px;width:50px;">
   <asp:Button  runat="server" id="WizardButton" style="width:170px;"  OnClientClick="openWin('<%# TextBoxOrderDetailID.Text %>'); return false;"   OnClick="rebindUsers" Text="Create Users"> </asp:Button>
      
    </div>
   <telerik:RadWindowManager ID="wizardWindowManager"           
            Behaviors=" Move, resize, close" Modal="true" ReloadOnShow = "true" BackColor="AliceBlue" ForeColor ="AntiqueWhite" KeepInScreenBounds="true"  runat="server"  Skin="Office2007" VisibleStatusbar="false"  BorderColor="AliceBlue" >
    </telerik:RadWindowManager>

.....

 <telerik:RadGrid ID="usersGrid" runat="server"  
       DataSourceID="ContentCentralUsers" GridLines="None" Skin="Office2007" AutoGenerateColumns="False"
            ondatabound="usersGrid_DataBound" onitemdatabound="usersGrid_ItemDataBound"   OnItemCreated="usersGrid_ItemCreated"
            onitemevent="usersGrid_ItemDataBound" oniteminserted="usersGrid_ItemInserted" onitemupdated="usersGrid_ItemUpdated"
            ShowStatusBar="True" OnPreRender="usersGrid_PreRender" oninsertcommand="usersGrid_InsertCommand" OnItemCommand="usersGrid_ItemCommand"
            onupdatecommand="usersGrid_UpdateCommand"   >
     
       <MasterTableView  DataSourceID="ContentCentralUsers"  DataKeyNames="user_id,package_cd"
             AllowFilteringByColumn="True" AllowSorting="True"   
              InsertItemPageIndexAction="ShowItemOnFirstPage" CommandItemDisplay="Top"
             NoMasterRecordsText="No users to display.">
            <CommandItemSettings AddNewRecordText="Add new user"  />
            
        
     <Columns>
        <telerik:GridEditCommandColumn ButtonType="ImageButton"  UniqueName="EditCommandColumn1">
                    <HeaderStyle Width="20px" />
        </telerik:GridEditCommandColumn>
        <telerik:GridBoundColumn DataField="user_id" UniqueName="user_id" Visible="false" ReadOnly="true" ></telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="package_cd" UniqueName="package_cd" Visible="false" ReadOnly="true" ></telerik:GridBoundColumn>

        <telerik:GridTemplateColumn HeaderText="Seat(User)" SortExpression="login_name" UniqueName="login_name" >
          <ItemTemplate>
             <asp:Label ID="login_name"   runat="server"  Text='<%#Eval("login_name") %>'></asp:Label>
          </ItemTemplate>
          <EditItemTemplate>
             <asp:TextBox ID="loginname" Text='<%#Eval("login_name") %>'  runat="server"  OnTextChanged="change_loginName"></asp:TextBox>
             <asp:RequiredFieldValidator id="loginnameRequiredFieldValidator" runat="server" ErrorMessage="* User name required" Display="Dynamic"
                ControlToValidate= "loginname"></asp:RequiredFieldValidator>
           </EditItemTemplate>
         </telerik:GridTemplateColumn>
         <telerik:GridTemplateColumn HeaderText="Password" SortExpression="password" UniqueName="password"  EditFormColumnIndex="1" AllowFiltering="false">
          <ItemTemplate>
             <asp:Label ID="password"   runat="server"  Text='<%#Eval("password") %>'></asp:Label></ItemTemplate>
             <EditItemTemplate>
              <asp:TextBox ID="editPassword" Text='<%#Eval("password") %>'  runat="server"  OnTextChanged="change_Password" ></asp:TextBox><asp:RequiredFieldValidator id="passwordRequiredFieldValidator" runat="server" ErrorMessage="* Password required" Display="Dynamic"
                  ControlToValidate= "editPassword"></asp:RequiredFieldValidator>
             </EditItemTemplate>
          </telerik:GridTemplateColumn><telerik:GridTemplateColumn HeaderText="Email" SortExpression="email" UniqueName="email" >
          <ItemTemplate>
             <asp:Label ID="email"   runat="server"  Text='<%#Eval("email") %>'></asp:Label></ItemTemplate><EditItemTemplate>
             <asp:TextBox ID="editEmail" Text='<%#Eval("email") %>'  runat="server"  OnTextChanged="change_email"></asp:TextBox><asp:RequiredFieldValidator id="emailValidator1" runat="server" ErrorMessage="* Email required"    Display="Dynamic"
                 ControlToValidate= "editEmail"></asp:RequiredFieldValidator><asp:RegularExpressionValidator Runat="server" ErrorMessage="* Invalid E-mail Address" ID="emailValidator2"  Display="Dynamic"
                 ControlToValidate="editEmail" ValidationExpression=".+@.+\.[a-z]+"></asp:RegularExpressionValidator></EditItemTemplate></telerik:GridTemplateColumn><telerik:GridTemplateColumn HeaderText="Package"  UniqueName="DefaultPackage" EditFormColumnIndex="1" >
                       <HeaderStyle Width="100%" />
                        <ItemTemplate>
                            <asp:Label runat="server" ID="Label1" Text='<%#..........



Javascript:
function openWin(OrderDetailID) {

        var urlArgs = cbeGetURLArguments();

        var sbOID = parseInt(urlArgs['sbOID']);
        var queryODID = parseInt(urlArgs['sbODID']);
        var sbproductid = parseInt(urlArgs['sbproductid']);
        var SAPID = urlArgs['SAPID'];

        var txtbxODID = document.getElementById('TextBoxOrderDetailID').value;
        var txtbxProduct = document.getElementById('TextBoxProduct').value;
        var licensePrice = document.getElementById('licensePrice').value;
        if (txtbxODID == null)
            sbODID = queryODID;
        else
            sbODID = txtbxODID;


        var windowURL = "v8Wizard_1.aspx?sbODID=" + sbODID + "&sbproductid=" + sbproductid + "&SAPID=" + SAPID +
                 "&lPrice=" + licensePrice + "&email=" + "" + "&ttt=" + "" + "&p_cd=" + "NTB" + "&sbOID=" + sbOID + "&numUsers=&packagePrice=0";

        var oWnd = radopen(windowURL, "RadWindow1");
        oWnd.setSize(650, 500);
        // oWnd.setSize(650, 600);
        oWnd.center();

        //set a function to be called when RadWindow is closed
        oWnd.add_close(OnClientClose);
    }
    function OnClientClose(oWnd) {


    }

    C#: but this is never getting executed
 protected void rebindUsers(Object sender, EventArgs e)
    {
        TextBoxOrderDetailID.Text = Session["orderDetailID"].ToString();
        CompanyInfoGrid.MasterTableView.Rebind();
        usersGrid.MasterTableView.Rebind();
    }

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 06 Nov 2008, 10:43 AM
Hi Laura,

Add "OnClientClose" event for RadWindow, and then call the AjaxRequest. At the server side you can rebind the RadGrid from the "RadAjaxManager1_AjaxRequest" method. Please try the following code snippets.

ASPX
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"
        <Windows> 
            <telerik:RadWindow runat="server" OnClientClose="closeRadWindow" Behavior="Default" InitialBehavior="None"  
                Left="" NavigateUrl="window.aspx" OpenerElementID="Button1"  
                style="display:none;" Top=""
            </telerik:RadWindow> 
        </Windows> 
</telerik:RadWindowManager> 

 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"  
        onajaxrequest="RadAjaxManager1_AjaxRequest"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadGrid1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    </form> 
</body> 
</html> 
 
<script type="text/javascript"
function closeRadWindow() 
 //   alert("RadWindow closed"); 
    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();  
</script> 



C#
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
        RadGrid1.MasterTableView.SortExpressions.Clear(); 
        RadGrid1.MasterTableView.GroupByExpressions.Clear(); 
        RadGrid1.Rebind(); 


Thanks,
Shinu.
0
Laura
Top achievements
Rank 1
answered on 06 Nov 2008, 03:41 PM
Thank you. That helps alot. My grid now rebinds. I also had to change code in the part that closes the window. I needed to call the javascript code from the c# codebehind when the button to save and close the window so that the users would get saved first and then the window closes so the rebind has the new users to work with.

Now, after the modal window closes and before the rebind takes place, I get this error:

Error:Sys.ArgumentUndefinedException:value cannot be undefined. Parameter name: handler
 I click no I don't want to debug, and then the grid rebinds fine, but what would be causing that error?

Thanks for you help,
Laura
0
Yavor
Telerik team
answered on 07 Nov 2008, 07:48 AM
Hello Laura,

Based on the supplied information, it is hard to determine what is causing the issue at hand.
If it persists, you can open a formal support ticket, and send us a small project, demonstrating the setup, and the unwanted behavior, for additional review.

All the best,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Laura
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Laura
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or