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

Problem with MultipleSelect

4 Answers 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hardiyanto
Top achievements
Rank 1
Hardiyanto asked on 05 Aug 2008, 04:43 AM

Hi there,

I am currently evaluating your RadGridView and I must say that I'm quite surprised. Your RadGridView control is easy and straight forward to use compare to other bigger brands in the market. It's very unfortunate that I had wasted several weeks evaluating other grid controls.

I'm currently having a problem with MultipleSelect when it's set to True. Please have a look at the following sample,

XAML code:

<Window x:Class="WpfApplication1.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="Window1" Height="412" Width="447" 
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
        xmlns:WpfApplication1="clr-namespace:WpfApplication1">  
    <Window.Resources> 
        <ObjectDataProvider x:Key="viewModel" ObjectType="{x:Type WpfApplication1:CustomerViewModel}" /> 
    </Window.Resources> 
    <Grid> 
        <telerik:RadGridView Name="uxdGrid" AutoGenerateColumns="False" 
                             ItemsSource="{Binding Source={StaticResource viewModel}, Path=CustomersList}">  
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn Width="100" IsReadOnly="False" DataType="{x:Null}" HeaderText="Customer Id" UniqueName="CustomerId" /> 
            </telerik:RadGridView.Columns> 
        </telerik:RadGridView> 
    </Grid> 
</Window> 
 

Code behind:

using System.Collections.Generic;  
using System.ComponentModel;  
using System.Windows;  
using System.Windows.Data;  
 
namespace WpfApplication1  
{  
    /// <summary>  
    /// Interaction logic for Window1.xaml  
    /// </summary>  
    public partial class Window1 : Window  
    {  
        public Window1()  
        {  
            InitializeComponent();  
        }  
    }  
 
    public class CustomerViewModel  
    {  
        public CustomerViewModel()  
        {  
            List<Customer> customers = new List<Customer>();  
 
            for (int i = 0; i < 10; i++)  
            {  
                Customer customer = new Customer();  
                customer.CustomerId = i;  
                customer.CustomerName = string.Format("Name {0}", i);  
                customers.Add(customer);  
            }  
 
            _view = new ListCollectionView(customers);  
        }  
 
        private readonly ListCollectionView _view;  
 
        public ListCollectionView CustomersList  
        {  
            get 
            {  
                return _view;  
            }  
        }  
    }  
 
    public class Customer : INotifyPropertyChanged  
    {  
        private int _customerId;  
        private string _customerName = string.Empty;  
 
        public int CustomerId  
        {  
            get 
            {  
                return _customerId;  
            }  
            set 
            {  
                _customerId = value;  
                SendPropertyChanged("CustomerId");  
            }  
        }  
 
        public string CustomerName  
        {  
            get 
            {  
                return _customerName;  
            }  
            set 
            {  
                _customerName = value;  
                SendPropertyChanged("CustomerName");  
            }  
        }  
 
        private event PropertyChangedEventHandler _propertyChanged;  
 
        public event PropertyChangedEventHandler PropertyChanged  
        {  
            add  
            {  
                _propertyChanged += value;  
            }  
            remove  
            {  
                _propertyChanged -= value;  
            }  
        }  
 
        /// <summary>  
        /// Raises the property changed event.  
        /// </summary>  
        /// <param name="propertyName">The property name which value has been changed</param>  
        protected void SendPropertyChanged(string propertyName)  
        {  
            if (_propertyChanged != null)  
            {  
                _propertyChanged(thisnew PropertyChangedEventArgs(propertyName));  
            }  
        }  
    }  
}  
 

It works as it's expected. But if you set the property MultipleSelect="True",

    <Grid>    
        <telerik:RadGridView Name="uxdGrid" AutoGenerateColumns="False" MultipleSelect="True"   
                             ItemsSource="{Binding Source={StaticResource viewModel}, Path=CustomersList}">     
            <telerik:RadGridView.Columns>    
                <telerik:GridViewDataColumn Width="100" IsReadOnly="False" DataType="{x:Null}" HeaderText="Customer Id" UniqueName="CustomerId" />    
            </telerik:RadGridView.Columns>    
        </telerik:RadGridView>    
    </Grid>    
 

You will notice that the grid is showing the correct number of rows but unfortunately it's not showing any data. Is there anything that I miss here?

Regards,

Hardi

4 Answers, 1 is accepted

Sort by
0
Hristo Deshev
Telerik team
answered on 05 Aug 2008, 03:36 PM
Hi Hardiyanto,

Thanks for the praise :-) It is Much appreciated, given that this is our first release.

I have used your code and reproduced the problem. It turns out you have hit a bug with our control. We do not initialize cells properly when somebody touches an internal object before columns have been added by the XAML parser. That internal object is used by the MultipleSelect property. For the time being, you can work around the bug by setting MultipleSelect after adding columns to the RadGridView control. The easy way to do this in XAML is to use the inline property set syntax:

<telerik:RadGridView Name="uxdGrid" AutoGenerateColumns="False"  
 
    ItemsSource="{Binding Source={StaticResource viewModel}, Path=CustomersList}"
    <telerik:RadGridView.Columns> 
        <telerik:GridViewDataColumn  IsReadOnly="False" DataType="{x:Null}" HeaderText="Customer Id" UniqueName="CustomerId" /> 
    </telerik:RadGridView.Columns> 
    <!-- Work around a RadGridView bug by setting MultipleSelect *after* adding columns --> 
    <telerik:RadGridView.MultipleSelect> 
        True 
    </telerik:RadGridView.MultipleSelect> 
</telerik:RadGridView> 
 

Note that the MultipleSelect property must appear *after* the Columns initialization.

Thanks for spotting the problem! I have updated your Telerik points.

Best wishes,
Hristo Deshev
the Telerik WPF team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hardiyanto
Top achievements
Rank 1
answered on 06 Aug 2008, 02:16 AM
Thanks for the reply, Hristo. I guess we can live with the workaround until your next release.

Regards,

Hardi
0
Gita
Top achievements
Rank 1
answered on 30 Sep 2011, 12:44 AM
Hello Telerik Team,
I tried to define the MultiSelect Property after the column initialization. But I am getting this error.

The attachable property 'MultipleSelect' was not found in type 'RadGridView'

Am I missing something?


Here is the XAML code

 

 

 

<telerik:RadGridView.Columns>

 

 

 

 

<telerik:GridViewDataColumn DataType="{x:Null}" IsReadOnly="True" IsResizable="True" IsFilterable="False" IsGroupable="False" IsSortable="True" UniqueName="OrderNumber" Header="Order" IsVisible="True" Width="70" />

 

 

 

 

</telerik:RadGridView.Columns>

 

 

 

 

 

<telerik:RadGridView.MultipleSelect>

 

True

 

 

 

</telerik:RadGridView.MultipleSelect>

 

0
Vlad
Telerik team
answered on 30 Sep 2011, 06:39 AM
Hello,

 Please use SelectionMode property instead. 

Best wishes,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Hardiyanto
Top achievements
Rank 1
Answers by
Hristo Deshev
Telerik team
Hardiyanto
Top achievements
Rank 1
Gita
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or