Hi,
I have a radDataFilter and radGridView. On a first place data is not loaded. I want after user put a some filter ( example: username start with: sa) to load data from the server based on the filter condition and show it on the grid.
I not see how to do this. In FilterDescriptors_ItemChanged event i capture what user ask to filter, send a request to load a data but it not show on the grid.
Please advise more better way to do this.
Best regards,
Saykor
I have a radDataFilter and radGridView. On a first place data is not loaded. I want after user put a some filter ( example: username start with: sa) to load data from the server based on the filter condition and show it on the grid.
I not see how to do this. In FilterDescriptors_ItemChanged event i capture what user ask to filter, send a request to load a data but it not show on the grid.
Please advise more better way to do this.
Best regards,
Saykor
5 Answers, 1 is accepted
0
Hello,
Vlad
the Telerik team
Can you post more info how the grid is bound in your case? Where you load the data once returned from the server?
Regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Saykor
Top achievements
Rank 2
answered on 09 Aug 2012, 12:51 PM
<telerik:RadDataFilter Name="radDataFilter"
Template="{StaticResource RadDataFilterTemplate}"
EditorCreated="OnRadDataFilterEditorCreated"
telerikControls:StyleManager.Theme="Vista"
Grid.Row="0"
EditorTemplateSelector="{StaticResource MyEditorTemplateSelector}"
Margin="1" />
<telerik:RadGridView Name="radGridView"
telerikControls:StyleManager.Theme="Vista"
Grid.Row="1"
ColumnWidth="*"
IsFilteringAllowed="False"
CanUserFreezeColumns="False"
RowIndicatorVisibility="Collapsed"
AutoGenerateColumns="False"
ItemsSource="{Binding FilteredSource, ElementName=radDataFilter}"
Margin="1">
void DataFilterExample_Loaded(object sender, RoutedEventArgs e)
{
radDataFilter.FilterDescriptors.ItemChanged += new EventHandler<ItemChangedEventArgs<IFilterDescriptor>>(FilterDescriptors_ItemChanged);
radDataFilter.Source = AppCache.AppViewModel.Data; //data is ObservableCollection<Report>
//add few filters that user can use immediately when window is loaded
}
void FilterDescriptors_ItemChanged(object sender, ItemChangedEventArgs<IFilterDescriptor> e)
{
if (AppCache.AppViewModel.Data.Count == 0 && ((e.Item as FilterDescriptor).Member.Equals("Salesperson") || (e.Item as FilterDescriptor).Member.Equals("RelationShipmanager")))
{
App.LoadData(() =>
{
// this function start BackgroundWorker and fill AppCache.AppViewModel.Data
// return result in callback.
//maybe here i need to start some method to run the filter or show the data but not see how... if I just do:
//radDataFilter.Source = AppCache.AppViewModel.Data;
//radGridView.ItemsSource = radDataFilter.FilteredSource;
//still not work
});
}
}
Template="{StaticResource RadDataFilterTemplate}"
EditorCreated="OnRadDataFilterEditorCreated"
telerikControls:StyleManager.Theme="Vista"
Grid.Row="0"
EditorTemplateSelector="{StaticResource MyEditorTemplateSelector}"
Margin="1" />
<telerik:RadGridView Name="radGridView"
telerikControls:StyleManager.Theme="Vista"
Grid.Row="1"
ColumnWidth="*"
IsFilteringAllowed="False"
CanUserFreezeColumns="False"
RowIndicatorVisibility="Collapsed"
AutoGenerateColumns="False"
ItemsSource="{Binding FilteredSource, ElementName=radDataFilter}"
Margin="1">
void DataFilterExample_Loaded(object sender, RoutedEventArgs e)
{
radDataFilter.FilterDescriptors.ItemChanged += new EventHandler<ItemChangedEventArgs<IFilterDescriptor>>(FilterDescriptors_ItemChanged);
radDataFilter.Source = AppCache.AppViewModel.Data; //data is ObservableCollection<Report>
//add few filters that user can use immediately when window is loaded
}
void FilterDescriptors_ItemChanged(object sender, ItemChangedEventArgs<IFilterDescriptor> e)
{
if (AppCache.AppViewModel.Data.Count == 0 && ((e.Item as FilterDescriptor).Member.Equals("Salesperson") || (e.Item as FilterDescriptor).Member.Equals("RelationShipmanager")))
{
App.LoadData(() =>
{
// this function start BackgroundWorker and fill AppCache.AppViewModel.Data
// return result in callback.
//maybe here i need to start some method to run the filter or show the data but not see how... if I just do:
//radDataFilter.Source = AppCache.AppViewModel.Data;
//radGridView.ItemsSource = radDataFilter.FilteredSource;
//still not work
});
}
}
0
Hello,
Vlad
the Telerik team
Can you try to assign AppCache.AppViewModel.Data to the grid ItemsSource directly to see what will be the result?
Kind regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Saykor
Top achievements
Rank 2
answered on 09 Aug 2012, 01:02 PM
I test this. If I assign it in FilterDescriptors_ItemChanged in call back function it still not work, not show the result.
after user change the filter again then result is showed. only first time not work.
But I load a data from our server only first time. Next when user change the filter will not load a data and filter the existing.
after user change the filter again then result is showed. only first time not work.
But I load a data from our server only first time. Next when user change the filter will not load a data and filter the existing.
0
Saykor
Top achievements
Rank 2
answered on 09 Aug 2012, 01:41 PM
My mistake. I test with radGridView.ItemsSource = radDataFilter.FilteredSource; in App.LoadData(() => and not work
Now i try radGridView.ItemsSource = AppCache.AppViewModel.Data; in App.LoadData(() => and data is showed on the grid and when user select other filter it work now
Now i try radGridView.ItemsSource = AppCache.AppViewModel.Data; in App.LoadData(() => and data is showed on the grid and when user select other filter it work now