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

Problem with GridViewComboBoxColumn

18 Answers 360 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 09 Jun 2009, 05:38 PM
 I have a gridViewComboBox column that doesn't seem to work as expected.  I'm able to popuplate it with the expected data but it seems like the comboBox is returning the displaydata in lieu of the valueData back to my BO property.  I've defined it in XML as:

<telerikGridView:GridViewComboBoxColumn   
                            x:Name="UserNamesComboBox" 
                            UniqueName="CollectedByIdDropDown" 
                            HeaderText="Collected By"   
                            DataMemberPath="CollectedById" 
                            DisplayMemberPath="Value" 
                            SelectedValueMemberPath="Key" 
                            IsReadOnly="False" /> 

and I populate it in codebehind:

private void InitializeUserDropdown()  
        {  
            ComboBoxEditorSettings comboBoxEditorSettings = new ComboBoxEditorSettings();  
            try 
            {  
                UserNameNvl.GetUserNameNvl((o, ex) =>  
                {  
                    if (ex.Error != null)  
                        MessageBox.Show(ex.Error.ToString(), "Data error", MessageBoxButton.OK);  
                    else comboBoxEditorSettings.ItemsSource = ex.Object;  
                });  
            }  
            catch (Exception ex)  
            {  
                MessageBox.Show(ex.ToString(), "Data error", MessageBoxButton.OK);  
            }  
 
            ((GridViewDataColumn)this.DataEntryWizardTasksGridView.Columns["CollectedByIdDropDown"]).EditorSettings = comboBoxEditorSettings;  
 
 
        } 

I'm using the same UserNameNvl object in my BO and it is working as expected with the key/value columns.  However what I am seeing is that no data is displayed in my grid column.  I can open the dropdown and I see my DisplayValues (full names) but when I select a value I'm not getting the key go back to the BO setter but the display value.  This basically means I set the value but then it doesn't match to anything in the dropdown keys so it looks like nothing is there.

I'm not seeing any binding error messages to make me thing I've got a typo or something.

18 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 12 Jun 2009, 01:15 PM
Hi Jack,

The ComboBox column has its own ItemsSource property.  Instead of  creating new ComboBoxEditor settings , please assign directly the itemssource of the column. It will automatically create the editor settings. When you create your own editor settings they will override the settings from XAML and I believe this is the cause of the problem.


So your code should look something like :

((GridViewComboBoxColumn)this.DataEntryWizardTasksGridView.Columns["CollectedByIdDropDown"]).ItemsSource = ex.Object; 

Instead of assigning new Combobox editor settings.

Let me know if you need further assistance on this issue.


Greetings,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jack
Top achievements
Rank 1
answered on 12 Jun 2009, 02:23 PM
That fixed the issue thanks.

Why is it that I can't speficy the itemsource property via XAML?  I get AG_PARSER errors as soon as I include anything related to ItemSource.
0
Pavel Pavlov
Telerik team
answered on 18 Jun 2009, 12:23 PM
Hello Jack,

I have made some tests here. There should not be any problem with setting ItemsSource in XAML .
If it is still an issue , you can send me the XAML and the codebehind ( ideally a project)  I can check it and tell you what is the reason for he exception.


Regards,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Pavel Pavlov
Telerik team
answered on 18 Jun 2009, 12:24 PM
Hello Jack,

I have made some tests here. There should not be any problem with setting ItemsSource in XAML .
If it is still an issue , you can send me the XAML and the codebehind ( ideally a project)  I can check it and tell you what is the reason for the exception.


Regards,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
sandy pochiraju
Top achievements
Rank 1
answered on 01 Oct 2009, 02:30 PM
hi Pavel, 

i tried in the way u suggested and i still dont get combobox in the gridview. 
this is what i have tried:
 ((GridViewComboBoxColumn)wipGridView.Columns["PackageType"]).ItemsSource = GetPackageTypeList();

please let me know if i am doing ath wrong here. even after i do this, my column does nt hv a combo box.

regards,
sandy
0
Pavel Pavlov
Telerik team
answered on 02 Oct 2009, 10:00 AM
Hello sandy pochiraju,

To have the ComboBox column ready for action you need to set the following properties:

1. ItemsSource /fills the combo with items/
2. DisplayMemerPath /tells the combo which property of the item to display/
3. SelectedValueMemberPath / tells the combo which property to store  after selection/
4. DataMemberBinding /tells the column which property from the RadGridView.ItemsSource to use/

If you wonder how to set these,  please have a look here.

In case you still have troubles I will be glad too have a look at your source and make the necessary adjustments.

*Also please note that the ComboBox will appear only when the cell is in edit mode e.g. the user clicks within a cell to start editing. When not in edit mode the cell will display just a textblock with the selected value.

All the best,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kevin Happe
Top achievements
Rank 1
answered on 26 Apr 2010, 10:32 PM
From the previous post
*Also please note that the ComboBox will appear only when the cell is in edit mode e.g. the user clicks within a cell to start editing. When not in edit mode the cell will display just a textblock with the selected value.

So the combobox will display the selected value when not in edit mode.  I would have hoped that it would have displayed the DisplayMember.   In our case the selected value is an ID and we want the text to be the Displaymember text.





0
Pavel Pavlov
Telerik team
answered on 28 Apr 2010, 12:36 PM
Hello Kevin Happe,

There seems to be a misunderstanding . Indeed as you expect , when in display mode, the cell will still respect the DisplayMemberPath and will show the display member rather than the ID. In case you have troubles setting up the properties , just let me know the details of your scenario and I may send  a small sample.

Best wishes,
Pavel Pavlov
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
Kevin Happe
Top achievements
Rank 1
answered on 28 Apr 2010, 02:52 PM
Somehow my project was using old versions of Telerik assemblies.  Updated my references and the issue went away.

I am having another issue, where the combobox doesnt update when the data is changed in the VM code and not via the GUI.  I have an example where it works correctly, but it just doesnt in my real code.  Still trying to track down the issue.  The bound field is raising PropertyChanged event, so I am not sure what is going on.  Still rearching it.
0
Pavel Pavlov
Telerik team
answered on 28 Apr 2010, 04:57 PM
Hi Kevin Happe,

Do you bind to a nested property ?


Sincerely yours,
Pavel Pavlov
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
Kevin Happe
Top achievements
Rank 1
answered on 28 Apr 2010, 05:01 PM
Yes, I am binding to a nested property.
Code is below.

 

GridViewColumns.Add(

new GridViewComboBoxColumn()

 

{

Header = alg,

 

DataMemberBinding = new Binding(string.Format("StateOptions[{0}].Value", colNbr))

 

{

Mode =

BindingMode.TwoWay

 

},

SelectedValueMemberPath =

"OrgValue",

 

DisplayMemberPath =

"ValueDescription",

 

ItemsSource = multiChoiceColumnData,

}

);

0
Kevin Happe
Top achievements
Rank 1
answered on 28 Apr 2010, 08:58 PM
Pavel,
Did you have a suggestion to help me fix my issue?

Thanks
Kevin
0
Pavel Pavlov
Telerik team
answered on 29 Apr 2010, 02:04 PM
Hello Kevin Happe,

Yes  , tomorrow( or Monday) there will be an internal build that  will include a fix for a  known issue with RadGridView not respecting property change notifications when combo column is bound to a nested property.
So my suggestion would be to to wait a day or tow and then upgrade with the fresh dlls from the Friday internal build .

Please excuse us for the inconvenience caused.

Regards,
Pavel Pavlov
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
Kevin Happe
Top achievements
Rank 1
answered on 29 Apr 2010, 02:50 PM
Pavel,

Thanks for the update.  I am glad you pointed out the issue, I was starting to get frustrated, thinking what didnt I hook up.

Thanks
Kevin Happe
Thomson Reuters
0
Kevin Happe
Top achievements
Rank 1
answered on 05 May 2010, 08:14 PM
I grabbed the daily build and it fixed my combobox binding issue.

However it broke the binding update for a column bound to a boolean value.

Is there a fix planned for that?

0
Pavel Pavlov
Telerik team
answered on 11 May 2010, 12:11 PM
Hi Kevin Happe,

Indeed there were some changes in the logic for binding to boolean values.
Can you please describe with some more details(XAML and/or code) your scenario and what exactly is broken.

I will try to provide a fix till the end of the week if possible.

Sincerely yours,
Pavel Pavlov
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
Kevin Happe
Top achievements
Rank 1
answered on 20 May 2010, 03:59 PM

I am having an issue with a checkbox column not responding to a change notification when the column is bound to a nested property.  I had the same issue with the combobox column.  The weekly build fixed the combobox column change notification, but broke the cneckbox column change notification.

 

GridViewColumns.Add(

 

new GridViewDataColumn()

 

{

Header = alg,

DataMemberBinding =

 

new Binding(string.Format("StateOptions[{0}].BooleanValue", colNbr))

 

{

Mode =

 

BindingMode.TwoWay

 

},

IsReadOnly =

 

false,

 

MaxWidth = 100,

DataType =

 

Type.GetType("System.Boolean")

 

 

 

});

 

0
Kevin Happe
Top achievements
Rank 1
answered on 20 May 2010, 09:11 PM
Nevermind, it was our bug.  Someone changed something they shouldnt have.
Tags
GridView
Asked by
Jack
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Jack
Top achievements
Rank 1
sandy pochiraju
Top achievements
Rank 1
Kevin Happe
Top achievements
Rank 1
Share this question
or