GANI
GANI

Reputation: 2049

filtering is not working for Telerik RadGridView Silverlight

I am using telerik radgridview whose item collection is domainsource bound to datapager I have 20 pages, when i filter on the column it just filters on the current page , how do i make it to filter on the whole collection. below is my code

           <telerikRad:RadGridView>
 ItemsSource="{Binding ElementName=stddata, Path=Data}" 
           <telerikRad:RadGridView.Columns>
           <telerik:GridViewDataColumn Header="stuName" DataMemberBinding="{Binding Name}" />
            <telerik:GridViewDataColumn Header="StuId" DataMemberBinding="{Binding StudentId}" />
              <telerikRad:RadGridView.Columns>
           <telerikRad:RadGridView>

            <sdk:DataPager Grid.Row="2"                                            
           x:Name="SSSS"                                            
          Source="{Binding Data, ElementName=stddata}"                                           
           IsTotalItemCountFixed="True" />

          <riaControls:DomainDataSource Name="stddata"                                                    
               AutoLoad="True"                                                                                                                    
               PageSize="9"                                                        
              QueryName="GetStudentsQuery"                                                        
              DomainContext="{Binding DomainContext}">
</riaControls:DomainDataSource>

Upvotes: 1

Views: 1294

Answers (1)

Mark Bostrom
Mark Bostrom

Reputation: 56

Telerik provides for getting the filtered items indirectly by applying the filter from the RadGridView to the collection that the control is bound to.

Here is a solution that allows one to get a filtered, sorted list of data items using the current filter and sort settings from a Telerik RadGridView control.

using Telerik.Windows.Data;
.
.
.
IEnumerable<MyClass> itemsToDisplay { get; set; }  //The RadGridView is bound to this property

public void DoSomethingWithFilteredAndSortedDisplayItems(RadGridView rgv)
{
    IQueryable<MyClass> iqItems = itemsToDisplay.AsQueryable();
    FilterDescriptorCollection filter = rgv.FilterDescriptors;
    SortDescriptorCollection sort = rgv.SortDescriptors;
    List<MyClass> fsItems = iqItems.Where(filter).Sort(sort).ToIList() as List<MyClass>;

    if (fsItems != null && fsItems.Count > 0)
    {
        DoSomethingWithDisplayItems(fsItems);
    }
}

public void DoSomethingWithDisplayItems(IEnumerable<MyClass> list)
{
    ... //Do something
}

This is for illustration. In my own code I implement the filter and sort as an extension method for the RadGridView control.

Upvotes: 2

Related Questions