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

Ajaxify Grid Filterbox Only

3 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Francois
Top achievements
Rank 1
Francois asked on 08 Apr 2014, 06:20 AM
Hello ! 

I'm trying to ajaxify the filter textboxes of my grid, and only them, so I don't want to use the following option : 

<telerik:AjaxSetting AjaxControlID="Grid" >
 <UpdatedControls>
  <telerik:AjaxUpdatedControl ControlID="Grid" LoadingPanelID="LoadingPanel2"/>
 </UpdatedControls>
</telerik:AjaxSetting>

Ideally, I would like to use the solution below, but the filter textboxes don't have a defined Id, so this is not an option either : 

<telerik:AjaxSetting AjaxControlID="FilterTextBoxId" >
 <UpdatedControls>
  <telerik:AjaxUpdatedControl ControlID="Grid" LoadingPanelID="LoadingPanel2"/>
 </UpdatedControls>
</telerik:AjaxSetting>

The only option I found is this one : 

protected void GridOnItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
  if (e.Item is GridFilteringItem)
  {
    GridFilteringItem dataItem = e.Item as GridFilteringItem;
    TextBox filterBox = dataItem["MyfirstColumn"].Controls[0] as TextBox;
    AjaxManager.AjaxSettings.AddAjaxSetting(filterBox, Grid, LoadingPanel2);
  }
}

But for some reason it's not working, when I set a filter on my "MyfirstColumn" the entire page is reloaded, the ajaxsetting seems to be completely ignored by the process. 

Any idea of what could be the reason ?

Thanks for your help ! 

<telerik:AjaxSetting AjaxControlID="Grid" >
 <UpdatedControls>
  <telerik:AjaxUpdatedControl ControlID="Grid" LoadingPanelID="LoadingPanel2"/>
 </UpdatedControls>
</telerik:AjaxSetting>

<telerik:AjaxSetting AjaxControlID="Grid" >
 <UpdatedControls>
  <telerik:AjaxUpdatedControl ControlID="Grid" LoadingPanelID="LoadingPanel2"/>
 </UpdatedControls>
</telerik:AjaxSetting>

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Apr 2014, 07:06 AM
Hi Francois,

You may try the following approach. You can use the OnCommand client-side event of RadGrid. This event will be fired for those controls that have a command name. In the event body you could check what is the command name and if it is the command name is not filter you could cancel the Ajax as shown below:

ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>
. . . . .
<ClientSettings>
    <ClientEvents OnCommand="gridCommand" />
</ClientSettings>

JS:
<script type="text/javascript">
    function gridCommand(sender, args) {
        debugger;
        if (args.get_commandName() != "Filter") {
            var manager = $find('<%= RadAjaxManager.GetCurrent(Page).ClientID %>');
            manager.set_enableAJAX(false);
 
            setTimeout(function () {
                manager.set_enableAJAX(true);
            }, 0);
        }
    }
</script>

Thanks,
Shinu
0
Francois
Top achievements
Rank 1
answered on 08 Apr 2014, 07:40 AM
Hey Shinu, 

Thanks for your help, your idea is really good but unhappily it wont work in my case.

I have one column containing textboxes in my grid and when the user change the content of those textboxes, I use ajax to refresh another linked column of the grid. But to do so I have to avoid to ajaxify the entire grid otherwise all the grid is refreshed each time the user change the content of the textbox. 

So I can't simply cancel ajax on my textboxes because I need it to refresh my linked content, that why I'm trying to find a way to ajaxify my filter textboxes :) 


 





0
Shinu
Top achievements
Rank 2
answered on 09 Apr 2014, 10:17 AM
Hi  Francois,

As per my knowledge this is not possible. After adding the whole RadGrid control to update itself when and inner control initiate an Ajax request the response will include the whole RadGrid contain in the response base on the updated control which is the whole RadGrid. Hence it cannot be implemented the way you are trying.

Thanks,
Shinu
Tags
Grid
Asked by
Francois
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Francois
Top achievements
Rank 1
Share this question
or