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

Rebind Only RadGrid in NestedViewTemplate

7 Answers 225 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 13 May 2013, 02:50 PM
At this point I have a RadGrid (RadGrid1) which contains a NestedTemplateView. Within this NestedTemplateView I have a RadTabStrip and a RadMultiPage View. On the first page of the RadMultiPage I have a second RadGrid(RadGrid2), which has a button to open a RadWindow. Within this RadWindow the user can select new records(saved to the source db), which I would like to appear in RadGrid2 when the RadWindow is closed. So what I am trying to figure out is how to rebind the "sender" grid (RadGrid2) and not the Parent Grid (RadGrid1). Any suggestions?

7 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 16 May 2013, 02:27 PM
Hello Rick,

You can try the following approach:
<ClientSettings>
    <ClientEvents OnRowClick="openWindow" />
</ClientSettings>
JavaScript:
var invoker = "";
function openWindow(sender, args) {
    invoker = sender.get_id();
    $find("<%= RadWindow1.ClientID %>").show();
}
function buttonInWindowClick() {
    window.top.$find(window.top.invoker).get_masterTableView().rebind();
}

Hope this helps. Please give it a try and let me know if it works for you.

Kind regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Rick
Top achievements
Rank 1
answered on 16 May 2013, 03:21 PM
Eyup,

Thank you for your help, however, it does not seem to be working for me. Currently I am launching the RadWindow via a CommandButton within RadGrid2. Furthermore, I am also unsure on where I need to execute the code below from. Currently, I am using the upper "X" to close the window, therefore, I do not have a button.

function buttonInWindowClick() {
    window.top.$find(window.top.invoker).get_masterTableView().rebind();
}
0
Eyup
Telerik team
answered on 21 May 2013, 12:36 PM
Hello Rick,

In that case, use the rebind logic on the ClientClose event.
That should do the trick. Looking forward to your reply when ready.

In addition, you can check out the following example:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=grid

Kind regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Amy
Top achievements
Rank 1
answered on 02 Aug 2016, 07:49 PM

I am experiencing a similar problem, and I feel that I must be missing something simple.

I have a radgrid which auto-refreshes with a Timer. 

I want my user to be able to click a hyperlink on a NestedViewTemplate in a radgrid, which will stop the timer and open a radwindow -- a separate page, not a content area -- where they will complete their data operations. On closing the radwindow (whether or not any data is updated), the radgrid should refresh and the timer should re-start.

so I am using 
ON PARENT PAGE
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script language="javascript" type="text/javascript">

        function openAttachmentsWindow(TicketID) {
            var timer = $find('<%= Timer1.ClientID %>');
            timer._stopTimer();
            var lbl = document.getElementById('<%= lblTimer.ClientID %>');
            lbl.innerHTML = 'waiting';

            var oWnd = radopen("TicketAttachments.aspx?id=" + TicketID, "radwinAttachments");
            return false;
        }

function refreshGrid(arg) {
            if (!arg) {
                document.getElementById('<%=lblTimer.ClientID%>').innerHTML = '';
                $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                $find("<%= lblTimer.ClientID%>")._startTimer();
                
            }
            else {
                document.getElementById('<%=lblTimer.ClientID%>').innerHTML = '';
                $find('<%= RadAjaxManager1.ClientID %>').ajaxRequest("RebindAndNavigate");
                $find('<%=Timer1.ClientID%>')._startTimer();
            }
        }
    </script>
</telerik:RadCodeBlock>

 

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

 

...radgrid...where I want the NestedViewTemplate to update!

<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" 
        AutoGenerateColumns="False" AllowAutomaticUpdates="True"  OnItemDataBound="RadGrid1_ItemDataBound" 
        OnPreRender="RadGrid1_PreRender" EnableLinqExpressions="false" OnItemCreated="RadGrid1_ItemCreated"
        OnItemCommand="RadGrid1_ItemCommand" OnDataBound="RadGrid1_DataBound" GridLines="Horizontal" AllowSorting="true" AllowPaging="true" PageSize="50" AllowFilteringByColumn="true" 
        >
        <MasterTableView Name="CallMasterID" DataKeyNames="CallMasterID" TableLayout="Auto" GridLines="Horizontal" CommandItemDisplay="Top" EnableViewState="false">

            <%-- panel to display details and buttons for radwindows --%>
            <NestedViewTemplate>......</NVT> etc

on its code-behind:

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "Rebind")
        {
            //RadGrid1.MasterTableView.SortExpressions.Clear();
            //RadGrid1.MasterTableView.GroupByExpressions.Clear();
            RadGrid1.DataSource = null;
            RadGrid1.CurrentPageIndex = 0;// GetDataTable(query);
            RadGrid1.Rebind();
        }
        else if (e.Argument == "RebindAndNavigate")
        {
            //RadGrid1.MasterTableView.SortExpressions.Clear();
            //RadGrid1.MasterTableView.GroupByExpressions.Clear();
            //RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1;
            //RadGrid1.Rebind();
            RadGrid1.DataSource = null;
            RadGrid1.CurrentPageIndex = 0;// GetDataTable(query);
            RadGrid1.Rebind();
        }
    }   

 

ON RADWINDOW PAGE (child) since I want the parent to update n o matter what, I put this in the Page_Unload event. is this causing a problem?

 

 protected void Page_Unload(object sender, EventArgs e)
    {
        ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);
    }

 

Basically, I have done all I can to follow the Grid/Window Integration demo and while my "waiting" label and timer get re-started when the CloseAndRebind() runs, the radgrid and its NVT don't update before the next timer Tick. Can you help?

Thanks!

Amy

0
Eyup
Telerik team
answered on 05 Aug 2016, 02:53 PM
Hi Amy,

This may be to some specific related to AJAX and the Timer. Please temporarily remove the AjaxManager and see whether the functionality will work as expected:
http://demos.telerik.com/aspnet-ajax/ajaxmanager/application-scenarios/ajaxify-timer/defaultcs.aspx

Regards,
Eyup
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Amy
Top achievements
Rank 1
answered on 08 Aug 2016, 06:15 PM

Thank you Eyup,

I did figure out how to get the timer to stop/start on desired RadWindow open and close.

The issue is that the radgrid and its NestedViewTemplate do not update after updating, but before the next timer Tick event. I must be missing what needs to be done to Ajaxify controls in the NestedViewTemplate of the radgrid. Sorry if I was unclear about that above. 

Any thoughts?

Thanks!

0
Eyup
Telerik team
answered on 11 Aug 2016, 11:44 AM
Hello Amy,

Please temporarily disable any AJAX on the page if present (RadAjaxManager, RadAjaxPanel, UpdatePanel, etc.) and enable your script debugger (FireBug or F12) to see whether there are any script or server errors interfering, and make sure that the application works without AJAX.

Then, you can try to wrap all of the controls within an asp:Panel and try setting it to the AjaxSettings of the RadAjaxManager alone. Or replace the manager with RadAjaxPanel and place all controls inside.


Regards,
Eyup
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Rick
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Rick
Top achievements
Rank 1
Amy
Top achievements
Rank 1
Share this question
or