Issue that combobox with VirtualQueryableCollectionView in RadGridView

4 posts, 0 answers
  1. Deng
    Deng avatar
    19 posts
    Member since:
    Apr 2012

    Posted 31 Mar 2013 Link to this post

    Hi Guys,

    I am very interested with Data virtualization, so I am refractoring my customer's old WPF project. Everything goes well but I encountered one critical issue when I use combobox with VirtualQueryableCollectionView  as GridViewDataColumn.CellEditTemplate.  Let me show it:

    1. I make below collection binding to my combobox
    private VirtualQueryableCollectionView _dataSource;
    public VirtualQueryableCollectionView DataSource
    {
        get
        {
            if (_dataSource == null)
            {
                _dataSource = new VirtualQueryableCollectionView(Manager.GetAll().AsQueryable()
                    .OrderBy(ExpressionHelper.CreateOrderByExpression<T>(DisplayName)))
                {
                    LoadSize = 20,
                    VirtualItemCount = _manager.GetCount(),
                };
                //_dataSource.ItemsLoading += ItemsLoading;
                //_dataSource.ItemsLoaded += ItemsLoaded;
            }
            return _dataSource;
        }
        set
        {
            if (Equals(_dataSource, value)) return;
            _dataSource = value;
            OnPropertyChanged("DataSource");
        }
    }
    2. I used GridViewDataColumn.CellEditTemplate with below 
    <telerik:GridViewDataColumn Header="{common:Translate RetailChain}"
                                               x:Name="Test"
                                               DataMemberBinding="{Binding BuyingOrganization.BO_CompanyName}">
                       <telerik:GridViewDataColumn.CellEditTemplate>
                           <DataTemplate>
                               <telerik:RadComboBox ToolTip="{common:Translate RetailChain_TT}"
                                                    SelectedValue="{Binding BuyingOrganization}"
                                                    ItemsSource="{Binding Source={StaticResource GlobalDataManager},Path= BuyingOrganizations.DataSource}"
                                                    DisplayMemberPath="{Binding Source={StaticResource GlobalDataManager},Path= BuyingOrganizations.DisplayName}" />
                           </DataTemplate>
                       </telerik:GridViewDataColumn.CellEditTemplate>
                   </telerik:GridViewDataColumn>

    3. when I change inner combobox's selection, my viewmodel BuyingOrganization can be changed. From surface,
     it work right.   But 
    if I take this cell out of Edit mode, the Null will be set to this BuyingOrganization. 

    I debug it, the VirtualQueryableCollectionView will call MoveCurrentPosition to one null value.

    How should I do? Can you give me some tips?

    Thanks & Regards

    Dely
  2. Deng
    Deng avatar
    19 posts
    Member since:
    Apr 2012

    Posted 31 Mar 2013 Link to this post

    Hi Guys,

    I am very interested with Data virtualization, so I am refractoring my customer's old WPF project. Everything goes well but I encountered one critical issue when I use combobox with VirtualQueryableCollectionView  as GridViewDataColumn.CellEditTemplate.  Let me show it:

    1. I make below collection binding to my combobox
    private VirtualQueryableCollectionView _dataSource;
    public VirtualQueryableCollectionView DataSource
    {
        get
        {
            if (_dataSource == null)
            {
                _dataSource = new VirtualQueryableCollectionView(Manager.GetAll().AsQueryable()
                    .OrderBy(ExpressionHelper.CreateOrderByExpression<T>(DisplayName)))
                {
                    LoadSize = 20,
                    VirtualItemCount = _manager.GetCount(),
                };
                //_dataSource.ItemsLoading += ItemsLoading;
                //_dataSource.ItemsLoaded += ItemsLoaded;
            }
            return _dataSource;
        }
        set
        {
            if (Equals(_dataSource, value)) return;
            _dataSource = value;
            OnPropertyChanged("DataSource");
        }
    }



    2. I used GridViewDataColumn.CellEditTemplate with below 

    <telerik:GridViewDataColumn Header="{common:Translate RetailChain}"
                                               x:Name="Test"
                                               DataMemberBinding="{Binding BuyingOrganization.BO_CompanyName}">
                       <telerik:GridViewDataColumn.CellEditTemplate>
                           <DataTemplate>
                               <telerik:RadComboBox ToolTip="{common:Translate RetailChain_TT}"
                                                    SelectedValue="{Binding BuyingOrganization}"
                                                    ItemsSource="{Binding Source={StaticResource GlobalDataManager},Path= BuyingOrganizations.DataSource}"
                                                    DisplayMemberPath="{Binding Source={StaticResource GlobalDataManager},Path= BuyingOrganizations.DisplayName}" />
                           </DataTemplate>
                       </telerik:GridViewDataColumn.CellEditTemplate>
                   </telerik:GridViewDataColumn>



    3. 
    when I change inner combobox's selection, my viewmodel BuyingOrganization can be changed. From surface,
     it work right.   But 
    if I take this cell out of Edit mode, the Null will be set to this BuyingOrganization. 

    I debug it, the VirtualQueryableCollectionView will call MoveCurrentPosition to one null value.

    How should I do? Can you give me some tips?

    Thanks & Regards

    Dely
  3. Deng
    Deng avatar
    19 posts
    Member since:
    Apr 2012

    Posted 31 Mar 2013 Link to this post

    Hi,

    I think I found the solution for this. The reason of this behavior is VirtualQueryableCollectionView  will manage the Current Item automatically. Because I use repository and unitofwork, so radcombobox's selectValve binding item will related VirtualQueryableCollectionView 's underlying data(DBcontext). So VirtualQueryableCollectionView ' current item
    change will affect selection value. I fixed it as disable VirtualQueryableCollectionView  CurrentItemChange behavior, below:


                /// <summary>
                /// The reason I add this , VirtualQueryableCollectionView will change inner current item, 
                /// this behavior will make our selection in UI uselessly 
                /// </summary>
                /// <param name="sender"></param>
                /// <param name="e"></param>
                void CurrentChanging(object sender, CurrentChangingEventArgs e)
                {
                    if (e.IsCancelable)
                        e.Cancel = true;
                }

  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 04 Apr 2013 Link to this post

    Hello,

    Thank you for sharing your solution with the community. 

    Kind regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top