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

popup window on CellEdit

2 Answers 58 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rayne
Top achievements
Rank 1
Rayne asked on 08 Jun 2011, 07:01 PM
I have a gridview and one of the columns needs a popup window for selecting the appropriate value because the list of available choices is over 200 records.

I've created a CellEditTemplate with a button bound to a command on my viewmodel, but I'm not sure this is the best approach. Because I have to bind the selectedItem of the grid to a property, so that when I show the popup window, it can alter the appropriate property of the selectedItem.

When I click on the "insert row", the new row isn't automatically the selected row. How do I get to to automatically be the selected row, so that my popup window has something to change? Or is there a better way to present the choices to the user besides a popup window?

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 09 Jun 2011, 08:36 AM
Hi Rayne,

Generally, the most appropriate solution depends entirely your the particular scenario you want to accomplish and the exact settings of your application.
Considering binding of the selected item, you may easily do it as follows:

public class MyViewModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
 
        private object selectedItem;
 
        public object SelectedItem
        {
            get { return this.selectedItem; }
            set
            {
                if (value != this.selectedItem)
                {
                    this.selectedItem = value;
                    this.OnPropertyChanged("SelectedItem");
                }
            }
        }
 
        protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (handler != null)
            {
                handler(this, args);
            }
        }
 
        private void OnPropertyChanged(string propertyName)
        {
            this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
        }
    }

If MyViewModel is the context of your grid, you can define the binding as follows:
<telerik:RadGridView Name="clubsGrid"
                         ItemsSource="{Binding Clubs}"
                         AutoGenerateColumns="False"
                         SelectedItem="{Binding SelectedItem}">


As for inserting a new item, you may subscribe to the AddingNewDataItem event and open the pop up in the handler.

Greetings,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rayne
Top achievements
Rank 1
answered on 09 Jun 2011, 02:10 PM
Thank you. I was able to finally get it working the way I needed it to. One of the things I love about WPF, it is so flexible!!
Tags
GridView
Asked by
Rayne
Top achievements
Rank 1
Answers by
Maya
Telerik team
Rayne
Top achievements
Rank 1
Share this question
or