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

Add RadAjax Manager to only Sort Command on RadGrid

1 Answer 28 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Aret
Top achievements
Rank 1
Aret asked on 02 Aug 2012, 12:10 PM
Hi, I was wondering if there was a way to add the radajaxmanager specifically to the sort command of a radgrid.  I am pretty sure this has to be done pro grammatically using Vb.net or C#.  For example here is an example where I specifically added the radajax functionality to a LinkButton control within a radgrid programmatically using VB.net.....

 Protected Sub Radgrid_AddRemoveProvider_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Radgrid_AddRemoveProvider.PreRender
       For Each item As GridDataItem In Radgrid_AddRemoveProvider.MasterTableView.Items
    
            Dim btnAddProvider As LinkButton = DirectCast(item.FindControl("btnAddProvider"), LinkButton)
            Dim btnRemoveProvider As LinkButton = DirectCast(item.FindControl("btnRemoveProvider"), LinkButton)

            'Add radajax functionality to only specific controls within radgrid
            radAjaxManager1.AjaxSettings.AddAjaxSetting(btnAddProvider, Radgrid_AddRemoveProvider)
            radAjaxManager1.AjaxSettings.AddAjaxSetting(btnRemoveProvider, Radgrid_AddRemoveProvider)
        Next

End Sub

Since the 'Sorting' within a radgrid is not a control, I do not know how to add it to the ajaxmanager.  Please Assist...

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 03 Aug 2012, 01:15 PM
Hello Aret,

You could enable ajax only on sorting command using the following approach:
  mark-up:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ClientEvents-OnRequestStart="requestStart">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

  JavaScript:
function requestStart(sender, args) {
    if (args.get_eventArgument().indexOf("Sort") < 0)
        args.set_enableAjax(false);
}

That should do the trick.

Greetings,
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.
Tags
Ajax
Asked by
Aret
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or