Load data after filter activate

6 posts, 0 answers
  1. Saykor
    Saykor avatar
    70 posts
    Member since:
    Feb 2011

    Posted 09 Aug 2012 Link to this post

    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
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Aug 2012 Link to this post

    Hello,

     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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Saykor
    Saykor avatar
    70 posts
    Member since:
    Feb 2011

    Posted 09 Aug 2012 Link to this post

    <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
                        });
                }
            }
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Aug 2012 Link to this post

    Hello,

     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.

  6. Saykor
    Saykor avatar
    70 posts
    Member since:
    Feb 2011

    Posted 09 Aug 2012 Link to this post

    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.
  7. Saykor
    Saykor avatar
    70 posts
    Member since:
    Feb 2011

    Posted 09 Aug 2012 Link to this post

    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 
Back to Top
UI for WPF is Visual Studio 2017 Ready