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

Updating different controls using different calls to AjaxRequest

3 Answers 120 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 09 Jul 2010, 03:27 AM
Hi,

I am using 2 RadGrids (master/detail) and RadAjaxManager to Ajaxify master detail loading and editing.

To edit the rows in the detail grid I use template columns with asp:Link controls for three different scenarios.

1> Edit (this opens a RadWindow with an edit form)
2> Deactivate/Activate (this opens a different RadWindow for confirmation) - Status column
3> Show/Hide (this also opens a RadWindow for confirmation) - Status column

There is also a Deactivate/Reactivate all link in the filteritem for a Status column (along with a RadComboBox for filtering).

All this functionality is working as desired with the details grid updated using Ajax on row select from the master grid and the filter combobox and various other buttons on the page updating the details grid correctly.

On closing the various Edit/Confirm windows I use a client-side AjaxRequest("Rebind") and handle the ajax request server-side with the ajax manager's OnAjaxRequest event handler (as demonstrated in various Telerik demos).

My one remaining issue is due to the fact that when returning from the "Edit" window I need to update the master grid as well as the detail grid to update various aggregate columns for the master grid. For all the "Confirm" windows, only the details grid needs to be updated.

<telerik:RadAjaxManager runat="server" ID="ramResourceManagement" OnAjaxRequest="ramResourceManagement_AjaxRequest">
    <AjaxSettings>
...
        <telerik:AjaxSetting AjaxControlID="ramResourceManagement">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="gridUnits" LoadingPanelID="ralpResourceManager" />
                <telerik:AjaxUpdatedControl ControlID="gridResources" LoadingPanelID="ralpResourceManager" />
                <telerik:AjaxUpdatedControl ControlID="headerPanel" />
            </UpdatedControls>
        </telerik:AjaxSetting>
...
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="ralpResourceManager" runat="server" EnableEmbeddedSkins="false" />

Using the above code for the radajaxmanager settings I update the controls correctly when a detail row (resource) is edited. But, of course, when a resource is deactivated or hidden etc. the master (unit) grid is also retrieved with the Ajax update (not updated but still adding large size to the response)

 I have used RadAjaxWithTarget to update only the resource grid from other controls on the page (asp buttons with onclientclick and onclick event handlers and relevant radajaxmanager settings for the button controls) but when attempting to do this on return from window close I am unsure of what target to use or what arguments.

I attempted to add a "refresh grid" button with Visible="false" and use this as the target then perform the grid refresh in it's onclick event handler as follows:

Script called on window close:
function RefreshResourceGrid()
{               
    $find("<%=ramResourceManagement.ClientID %>").ajaxRequestWithTarget("<%= btn_refreshGrid.UniqueID %>", "");
}

Relevant RadAjaxManager Settings and button control:
        <telerik:AjaxSetting AjaxControlID="btn_refreshGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="gridResources" LoadingPanelID="ralpResourceManager" />
            </UpdatedControls>
        </telerik:AjaxSetting>
 
<asp:Button runat="server" ID="btn_refreshGrid" OnClick="btn_refreshGrid_Click" CausesValidation="false" Visible="false"/>

Code behind:
protected void btn_refreshGrid_Click(object sender, EventArgs e)
{
    BindResources();
}

Unfortunately this causes a full postback despite the ajax settings suggesting an ajax update on only the resources grid should be performed.

Any ideas?

3 Answers, 1 is accepted

Sort by
0
Accepted
Maria Ilieva
Telerik team
answered on 13 Jul 2010, 12:51 PM
Hi Lourein,

The last suggestion you described is a correct one except that you could not add invisible controls into the RadAjaxManager settings. All controls added as ajax initiator or updated controls should be always visible on the page. Therefore I suggest you to wrap the button in always visible container (asp Panel for example) and add this container into the RadAjaxManager setting instead of the button itself.
Let me know if this helps.


Sincerely yours,
Maria Ilieva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jason
Top achievements
Rank 1
answered on 14 Jul 2010, 02:31 AM
Hi Maria,
Thanks for your response.

Unfortunately if the button is not used as the ajax request target the OnClick event handler is not triggered so the resource grid is not rebound.

Also, using the panel as target is still causing a postback.
0
Jason
Top achievements
Rank 1
answered on 14 Jul 2010, 02:58 AM
Hi Maria,

I have tested and confirmed that setting the button to visible has the desired effect but this is not ideal as even setting the width to 0 doesn't seem to get rid of the button.

I have changed the Button to a LinkButton with Text="" and this has the desired effect.

Thanks for your help.

Cheers
Tags
Ajax
Asked by
Jason
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Jason
Top achievements
Rank 1
Share this question
or