Reputation: 11
When exporting a rad grid data if the user has it filtered in any way the grid should just export the filtered data not the entire dataset - Any idea how to achieve this?
Regards - Hemant
Upvotes: 1
Views: 2491
Reputation: 56
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 (Silverlight version).
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
}
Upvotes: 2
Reputation: 2266
I think that if you assign the filtered set of data to the grid before calling the export method (which internally rebinds it), you will get the filtered values in the exported file.
Upvotes: 0