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

GridViewComboBoxColumn Not Displaying Selected Value

7 Answers 1527 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Corey
Top achievements
Rank 2
Corey asked on 16 Jan 2013, 10:37 PM

Hello,

                I’m having some issues with a GridViewComboBoxColumn.  I am binding a List of items to populate the combo box.  My overall data structure is as follows.  My grid’s ItemsSource is a List of ActionListInfo items.  Each ActionListInfo contains:  string ActionName, int SequenceNumber, DrillDownSource DDSource, List<DrillDownSource> PossibleSources.  Each instance of DrillDownSource contains:  int Id, string Name.  Note that the list of PossibleSources is different between each ActionListInfo and can change dynamically.

                My grid consists of a column displaying each ActionListInfo’s name, a column displaying their sequence #, and their selected DrillDownSource (the combo box column).  First off, the combo box does not display anything until it is clicked.  The combo box then correctly displays the possible options for that row’s DrillDownSource.  Selecting one of these choices correctly fires the DDSource_Changed listener and even sets the DDSource of that row’s ActionListInfo properly (I know this because I’ve added a test column that is bound to each ActionListInfo’s DDSource property and it updates correctly after selecting a choice).

                The problem I’m having is that even after a selection is made, once the user clicks away from the combo box (leaving edit mode I suppose), the cell goes blank.  I know the value was selected, but no value is displayed in the comb box cell.  It’s just empty.  It’s worth noting that when my listener DDSource_Changed is called, it does its own rebinding of the grid.  It clears the grid’s ItemsSource and then sets it to the list of ActionListInfo items (one of which has a newly defined DDSource).  Please look at the included pictures in order to better understand.

                Is there any way to set the SelectedValue property of the combo box in the column?  I would like to set it to the DDSource of each ActionListInfo (this DDSource is updated correctly each time the combo box is used).  If not, please tell me what I might be doing wrong.  Is there a specific binding similar to SelectedValueMemberPath that is used to determine which choice to display?  My binding for this particular column is shown below.

Please note that I do all of my work in the code.  I do not use any XAML.  Also, sorry for the wall of text.

 

GridViewComboBoxColumn ddSource = new GridViewComboBoxColumn();

ddSource.ItemsSourceBinding = new System.Windows.Data.Binding("PossibleSources");

ddSource.DataMemberBinding = new System.Windows.Data.Binding("Id");

ddSource.Header = "Drill-Down Source";

ddSource.DisplayMemberPath = "Name";

ddSource.SelectedValueMemberPath = "Id";

ddSource.IsReadOnly = false;

ddSource.EditTriggers = Telerik.Windows.Controls.GridView.GridViewEditTriggers.CellClick;

_grid.Columns.Add(ddSource);

_grid.AddHandler(RadComboBox.SelectionChangedEvent, new Telerik.Windows.Controls.SelectionChangedEventHandler(DDSource_Changed));

_grid.ItemsSource = _actions;

7 Answers, 1 is accepted

Sort by
0
Accepted
Yoan
Telerik team
answered on 21 Jan 2013, 06:23 PM
Hello Corey,

I have tested your scenario, using the code snippet you provided, but I was not able to reproduce this problem. For you convenience, I have attached a sample project. Would it be possible to modify it in order to reproduce the problem and resend it back to me ?

Moreover, I can suggest you check this help article, where you can find a detailed information about the GridViewComboBoxColumn.

Greetings,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Corey
Top achievements
Rank 2
answered on 21 Jan 2013, 07:58 PM
My apologies.  I had determined the reason for my problem but forgot to update this post.  Thank you for your reply.

My problem was solely with the binding and my understanding (or lack thereof) as to how it worked.  I had incorrectly setup the DataMemberBinding for the column.  I was trying to set it to the ID property of the DrillDownSource class used to populate the combo box.  What I needed to do was to set the DataMemberBinding to a property of the grid's ItemsSource class (I called the property SelectedDrillDownSource).  This is what ultimately sets the appropriate binding for the selected value of the combo box and now my combo box column is working as intended.  It populates, selects, displays, and updates correctly.
0
Rodro
Top achievements
Rank 2
answered on 22 Jan 2013, 12:18 PM
Hi,

I'm experiencing the same kind of problem, GridViewComboBoxColumn is not displaying the selected value in "view mode" although the edit mode works ok.

Interestingly, when a cell in that column is in edit mode all the other cells in the same column would display the correct value in view-mode, but as soon as I tab out the whole column gets cleared (although the selected values would stay in place).

I'm using the Binaries.NoXaml assemblies with default Windows8 theme files and I suspect that there is a bug in this flavor of the theme, as it happened before...

Or am I missing something obvious?


Version is 2012.3.1017.1050

I'm attaching two screenshots to prove what I say.

Here is my (reduced) xaml:
<telerik:RadGridView Grid.Row="1"
                           CanUserInsertRows="True"
                           CanUserDeleteRows="True"
                           CanUserSelect="True"
                           CanUserSortColumns="False"
                           ShowGroupPanel="False"
                           IsReadOnly="False"
                           AutoGenerateColumns="False"
                           IsFilteringAllowed="False"
                           EditTriggers="CellClick"
                           ActionOnLostFocus="CommitEdit"
                           ItemsSource="{Binding Path=Columns, Mode=OneWay}"
                           SelectedItem="{Binding Path=SelectedColumn, Mode=TwoWay}">
        <telerik:RadGridView.Columns>
          <telerik:GridViewDataColumn Header="Posizione" UniqueName="Position" EditorStyle="{StaticResource gridTextEditorStyle}" DataMemberBinding="{Binding Path=Position, Mode=OneWay}" IsReadOnly="True"/>
          <telerik:GridViewMaskedTextBoxColumn Header="Dimensione" UniqueName="Length" EditorStyle="{StaticResource gridMaskedTextEditorStyle}" MaskType="Standard" Mask="####" DataMemberBinding="{Binding Path=Length, Mode=TwoWay}"/>
          <telerik:GridViewDataColumn Header="Nome" UniqueName="Name" EditorStyle="{StaticResource gridTextEditorStyle}" DataMemberBinding="{Binding Path=Name, Mode=TwoWay, ValidatesOnDataErrors=True}" ValidatesOnDataErrors="None"/>
          <telerik:GridViewComboBoxColumn  Header="Tipo" UniqueName="DataType" EditorStyle="{StaticResource gridComboEditorStyle}" ItemsSource="{Binding Path=DataTypes, Mode=OneTime}" SelectedValueMemberPath="Value" DisplayMemberPath="Key" DataMemberBinding="{Binding Path=DataType, Mode=TwoWay}" IsComboBoxEditable="False"  />
          <telerik:GridViewComboBoxColumn  Header="Allineamento" UniqueName="Alignment" EditorStyle="{StaticResource gridComboEditorStyle}" ItemsSource="{Binding Path=Alignments, Mode=OneTime}" SelectedValueMemberPath="Value" DisplayMemberPath="DisplayText" DataMemberBinding="{Binding Path=Alignment, Mode=TwoWay}"  IsComboBoxEditable="False"/>
          <telerik:GridViewDataColumn Header="Riempimento" UniqueName="Padding" EditorStyle="{StaticResource gridTextEditorStyle}" DataMemberBinding="{Binding Path=Padding, Mode=TwoWay}"/>
          <telerik:GridViewDataColumn Header="Formattazione" UniqueName="FormatString" EditorStyle="{StaticResource gridTextEditorStyle}" DataMemberBinding="{Binding Path=FormatString, Mode=TwoWay}" />
        </telerik:RadGridView.Columns>
 
      </telerik:RadGridView>

Note that the editor style is just clearing any default margin and border thickness, nothing else.

The itemsSource is a Dictionary<string,Type> I use to present the user with friendly type names.
The "DataType" member on my item is of type "Type".

Please Help!

-Rodrigo


0
Yoan
Telerik team
answered on 24 Jan 2013, 04:00 PM
Hi Rodrigo,

I can suggest you to run through this troubleshooting article for a reference.

Please, let me know if you need further assistance on this.

Greetings,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Muhammad Owais
Top achievements
Rank 1
answered on 30 Jul 2015, 05:35 AM

Hi Yoan,

I am very new to telerik therefore apologies in advance. I am facing the same issue. I have even went through http://docs.telerik.com/devtools/silverlight/controls/radgridview/troubleshooting/blank-cells yet couldn't solve the problem.

 

My model is as follows :

 public class Role
    {
        [DataMember]
        public int pkOperatorRoleId { get; set; }
        
        [DataMember]
        public string Description
        { get; set; }
    }

 public class OperatorModel
    { 

 [DataMember]
        public int PkOperatorDetailId { get; set; }
        [DataMember]
        public int RoleId { get; set; }
        [DataMember]

        public string UserName
        { get; set; }
        [DataMember]

        public string Name
        {
            get;
            set;
        }​}

MainPage.Xaml : 

<telerik:GridViewComboBoxColumn UniqueName="Role"  DataMemberBinding="{Binding pkOperatorRoleId, Mode=TwoWay}"  SelectedValueMemberPath="RoleId" DisplayMemberPath="Description" Width="*" Header="Role"></telerik:GridViewComboBoxColumn>

 MainPage.cs :

 ObservableCollection<Role> itemSourceRole;

void client_GetRoleCompleted(object sender, GetRoleCompletedEventArgs e)
        {
            itemSourceRole = e.Result;
            

            ((GridViewComboBoxColumn)this.tblGridView.Columns["Role"]).ItemsSource = itemSourceRole;
             
        }​

 

as soon i click on anywhere on my grid the combobox selected value disappears and shows the wmpty cell. Please help!

 

0
Dimitrina
Telerik team
answered on 03 Aug 2015, 12:32 PM
Hello,

You populate GridViewComboBoxColumn with Role objects and there is not property RoleId defined for them.
I believe you should switch the way you set the Binding to:
DataMemberBinding="{Binding RoleId, Mode=TwoWay}" SelectedValueMemberPath="pkOperatorRoleId

How does this work for you?

Regards,
Dimitrina
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Muhammad Owais
Top achievements
Rank 1
answered on 13 Aug 2015, 04:36 AM
Yes it does! Thanks alot.
Tags
GridView
Asked by
Corey
Top achievements
Rank 2
Answers by
Yoan
Telerik team
Corey
Top achievements
Rank 2
Rodro
Top achievements
Rank 2
Muhammad Owais
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or