<
telerik:RadGridView
x:Name
=
"demographicList"
ShowGroupPanel
=
"False"
ShowInsertRow
=
"True"
Height
=
"300"
Width
=
"800"
AutoGenerateColumns
=
"False"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewComboBoxColumn
Header
=
"Name"
ItemsSource
=
"{Binding DemographicsList}"
DisplayMemberPath
=
"Demographic"
DataMemberBinding
=
"{Binding DemographicID}"
SelectedValueMemberPath
=
"DemographicID"
UniqueName
=
"DemographicsName"
/>
<
telerik:GridViewDataColumn
Header
=
"Value 1"
UniqueName
=
"Value1"
/>
<
telerik:GridViewDataColumn
Header
=
"Value 2"
UniqueName
=
"Value2"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
15 Answers, 1 is accepted
May I ask you to check this help article about GridViewComboBoxColumn and try the approach suggested there?
As to your question related to the two data columns, I do not see their DataMemberBinding set. Would you please share more details on how are they bound?
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I am a little confused by your response in regards to the GridViewComboBoxColumn. I do not have empty cells when I click in the cell and the drop-down shows. It is after I choose an entry in the drop-down and then tab away from that cell. The selection no longer appears to the user. It is still in the drop-down but is no longer selected.
Thanks and let me know.
I apologize for this misunderstanding. I am still not able to reproduce such an issue locally. May I ask you to check whether you have set the appropriate settings as suggested in our documentation about GridViewcomboBoxColumn? Do you have a property "DemographicID" defined for the objects in the "DemographicsList" collection? If you have such a property, would it be possible for you to isolate the issue in a demo project which we could debug locally?
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
If we can, I would like to take a step back and describe what I am trying to do.
My grid view will have 4 columns. 2 with gridviewcomboboxcolumns and 2 with gridviewdatacolumns.
The 2 columns with the comboboxes, I want to have the ItemsSource to 2 different ObservableCollections that consist of 2 different Models.
Example of Demographics Model:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.ComponentModel;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Events;
using System.Diagnostics;
namespace Geomentum.MediaReach.Infrastructure.Models
{
public class DemographicsModel
{
private int _demographicID = 0;
private string _demographic = "";
public int DemographicID
{
get { return _demographicID; }
set
{
_demographicID = value;
}
}
public string Demographic
{
get { return _demographic; }
set
{
_demographic = value;
}
}
}
}
I then call a function that in turn calls a wcf service to populate the ObservableCollection of the DemographicsModel
private void LoadDemographics()
{
DemographicsServiceClient service = new DemographicsServiceClient();
service.GetDemographicsCompleted += new EventHandler<
GetDemographicsCompletedEventArgs
>(DisplayDemographics);
service.GetDemographicsAsync();
}
void DisplayDemographics(object sender, GetDemographicsCompletedEventArgs e)
{
this.DemographicsList.Clear();
DemographicsDetails serviceResponse = e.Result;
ObservableCollection<
DemographicsModel
> oc;
oc = new ObservableCollection<
DemographicsModel
>(serviceResponse.DemographicsDetail.DemographicsDetails);
this.DemographicsList = oc;
OnPropertyChanged("DemographicsList");
}
At this point when the program runs, the system goes through these functions and populates the grid. I click on the line that states 'Click here to add new item'. The line clears and a click in the first cell. I see my drop down of Demographic entries. I click on one and then tab to the next cell. My selection is unselected and the cell is blank. (It still has all the entries.)
Now the other wrinkle to what I am trying to do. I want the gridview to have a seperate ItemsSource that will be a different ObservableCollection filled with a different Model. This Model will also have a DemographicID as a property. This model will be filled in with saved information so that when the user comes back to the page, they should see the lines they previously entered, with the Demographic value they previously selected, automatically selected. That way they can change if needed or leave it the same. Can this be done. Can this be done?
I have a small application that I can send you to show you the behaviour. It is a zip file that is 13mb. How do I get it to you?
You can open a support thread and attach it there. It would be better if you clean it from all the code not related to the problem so that we could concentrate on the problem.
Regards,Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
If you are interested and have access, I just submitted a Support Thread with the following as my ticket number.
564244
I might have found part of the issue. I was never setting the ItemsSource of the gridview to a source. In the test application I create another object that had 3 properties: DemographicID, Value1, Value2. I created 5 objects and added them to an ObservableCollection. Upon running the program, it looks like my grid is populated correctly with the objects and their values and the selections in the 1st column (combo box) are selected correctly. You see 5 rows in the gridview.
Here is the issue still: When it first comes up the columns that are combo boxes don't show anything to the user, but upon hightlighting one of the cells all 5 show the correct selections. I then tab off of the cell and all 5 disappear again, but do retain any changes. So I guess my question is why is the information only showing when I click in the cell or on a row header?
I have attached screen prints.
Thank you for that update.
Please, lets continue the further communication into the support thread.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Any response for this ticket # 564244, even I have the same issue and no where I get the answer in any blogs.
If you hear from any one or if you resolve the issue could you please share the solution. It would be great help.
Thank You,
Madhu Rao
mrao0179@gmail.com
In the support thread I suggested him to predefine the CellTemplate for the column and place a ComboBox as a DataTemplate. Then set its ItemsSource appropriately.
Hopefully that way the values will be populated as expected.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Can you share some code snippet please.
Regards,
Madhu Rao
You can check this help article on how to predefine the CellTemplate for a column. Then you should configure the ComboBox having in mind that the DataContext for it will be the data item bound for the parent GridViewRow.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I am facing the same issue. Did you get this working?
Can you confirm that you have tried the approaches suggested from Dimitrina? It will be great if you can send us isolated project from your application reproducing this behavior. This way we can directly investigate it on our side.
Regards,
Dinko
Progress Telerik