This is a migrated thread and some comments may be shown as answers.

Issue that combobox with VirtualQueryableCollectionView in RadGridView

3 Answers 140 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Deng
Top achievements
Rank 1
Deng asked on 31 Mar 2013, 10:47 AM
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 Answers, 1 is accepted

Sort by
0
Deng
Top achievements
Rank 1
answered on 31 Mar 2013, 02:34 PM
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
0
Deng
Top achievements
Rank 1
answered on 31 Mar 2013, 06:40 PM
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;
            }

0
Dimitrina
Telerik team
answered on 04 Apr 2013, 10:03 AM
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.

Tags
GridView
Asked by
Deng
Top achievements
Rank 1
Answers by
Deng
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or