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

Filter problems.

1 Answer 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 17 Feb 2014, 02:09 PM
I have a RadGrid driven by a LinqToSQL data layer that returns a dataset for binding.  I also have custom paging implemented.  Under normal conditions the data layer only returns a page's worth of data, 10 to 15 records.  If a filter is entered, custom paging is turned off and the entire data set is returned.  Normally this is not a burden as the total data set is usually around 100 records or so and the users know that filtering slows things down a bit.

However I've just seen some behavior I can't explain.   The field most likely to be filtered on is a varchar(max), although for display purposes only the first 75 char are displayed. 

The problem is as follows: The filter works but only if a Refresh of the grid is done first.  (i.e. doing 2 filters in a row will not work.)  Otherwise it seems to hang. 
I've seen this same problem using both old and new versions of the RadGrid.  (Our production version is running a 2012 version.  I have the latest on my development machine.)  

What could I be missing?


As currently implemented the Refresh button calls the following code.
  
                RadGrid1.MasterTableView.SortExpressions.Clear();

                // Clear all filters
                foreach (GridColumn column in RadGrid1.MasterTableView.OwnerGrid.Columns)
                {
                    column.CurrentFilterFunction = GridKnownFunction.NoFilter;
                    column.CurrentFilterValue = string.Empty;
                }

                RadGrid1.MasterTableView.FilterExpression = string.Empty;

                RadGrid1.Rebind();

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Feb 2014, 05:31 AM
Hi Boris,

Below is a sample code snippet that I tried but I was not able to replicate such an issue.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server"  AllowPaging="true" AllowCustomPaging="true" AllowSorting="true" AllowFilteringByColumn="true" VirtualItemCount="100" OnNeedDataSource="RadGrid1_NeedDataSource">
    <MasterTableView CommandItemDisplay="Top">
        <CommandItemTemplate>
            <asp:ImageButton ID="ClearFilter" runat="server" AlternateText="ClearFilter" OnClick="ClearFilter_Click" />
        </CommandItemTemplate>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
  int startRowIndex = RadGrid1.CurrentPageIndex * RadGrid1.PageSize;
  int maximumRows = RadGrid1.PageSize;
  DataTable table = new DataTable();
  for (int i = 0; i < 5; i++)
  {
      table.Columns.Add(new DataColumn("Column" + i));
  }
  for (int i = 0; i < maximumRows; i++)
  {
      int index = i + startRowIndex;
      table.Rows.Add(new object[] { "Cell1" + index, "Cell2" + index, "Cell3" + index, "Cell4" + index, "Cell5" + index });
  }
  RadGrid1.DataSource = table;
}
protected void ClearFilter_Click(object sender, ImageClickEventArgs e)
{
  RadGrid1.MasterTableView.SortExpressions.Clear();
  
  foreach (GridColumn column in RadGrid1.MasterTableView.OwnerGrid.Columns)
  {
      column.CurrentFilterFunction = GridKnownFunction.NoFilter;
      column.CurrentFilterValue = String.Empty;
  }
  RadGrid1.MasterTableView.FilterExpression = String.Empty;
  RadGrid1.Rebind();
}

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