jdag jdag - 6 months ago 133
Javascript Question

how to clear filtering, sorting and paging on a webdatagrid on client side?

I have a webdatagrid which retains data on searching in text box. I have noticed when I filter/page/sort the data and before clearing any of these I make a new search then the new search results retains previous filter/page/sort condition. I am not clearing it before reloading the page. I have search method on client side and I am using following code which does not work:

function btnSearch_click(sender, evntArgs){
var grid = $find('<%= grid1.ClientID %>');
grid.get_behaviors().get_filtering().clearColumnFilters();
grid.get_behaviors.get_sorting().clearColumnSorting();
grid.get_behaviors.get_paging().clearPaging();
}


This code is incorrect.

Answer

since my grid loads on hitting search button. I used following on server side:

if (search == "True")
              {
                  var filtering = grid1.Behaviors.Filtering;
                  this.grid1.Behaviors.Sorting.SortedColumns.Clear();
                  this.grid1.Behaviors.Paging.PageIndex = 0;
                  grid1.Behaviors.Filtering.ClearBehaviorColumnInfo();
                  this.grid1.Behaviors.Filtering.ColumnFilters.Clear();
                  filtering.FilterType = Infragistics.Web.UI.GridControls.FilteringType.RowFilter;
                  filtering.FilterType = Infragistics.Web.UI.GridControls.FilteringType.ExcelStyleFilter;
                  grid1.Behaviors.Filtering.ApplyFilter();

              }

I wanted to implement excel style filter and infragistics had no way to reproduce excel filter after clearing it I had to apply row type filter first and then change the filter type to excel type.

Comments