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

Separate ItemsSource for each newly added GridViewComboBoxColumn

4 Answers 58 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tigran
Top achievements
Rank 1
Tigran asked on 13 Sep 2013, 11:09 AM
Hi Telerik,

I have written new GridView control. And I'm adding new columns to that control programmatically on some button click.
I've exposed dependancy property from which I'm taking the ItemsSource for newly added GridViewComboBoxColumn.
So that ItemsSource almost has nothing common with Grid's DataContext.

And I'm trying to set that ItemsSource:
GridViewComboBoxColumn column = new GridViewComboBoxColumn ();
column.ItemsSource = MyItemsSource;
column.DataMemberBinding = new Binding(PreviousColumnDataMemberBinding.Path.Path);

After that I'm adding that column to my GridView Columns.
And after running the program I notice that the given ItemsSource ignored and instead used previous GridView.ItemsSource.

So my question is how can I force to use my newly given ItemsSource for each newly added column.
Also I've already looked on different tutorials, threads but that doesn't help me.
Thanks in advance.

Kind Regards,
Tigran

 

4 Answers, 1 is accepted

Sort by
0
Tigran
Top achievements
Rank 1
answered on 17 Sep 2013, 11:06 AM
It seems I'm examining empty cells in GridViewComboBoxColumn problem.
I wonder if it is possible to fix this issue in some release. I'm using version 2013.1.0403.1050.
0
Dimitrina
Telerik team
answered on 17 Sep 2013, 11:59 AM
Hello Tigran,

I am not sure why your ItemsSource cannot be set as you set it in code. The code seems fine and if the collection has items then they should be populated. You can check our online documentation on problems with empty cells in the column.

Then, I would suggest you to go through this documentation article on how you should configure the column properly. Then, you can check the "ComboBox Column" demo here.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Tigran
Top achievements
Rank 1
answered on 18 Sep 2013, 06:57 AM
Hi Didie,

Actually I've already tried all your suggestions.
Let me explain the problem more accurate.

As I mentioned in my original post I'm writing user control (GridView).
I'm using MVVM pattern.
And I'm adding columns programmatically to my grid:

GridViewComboBoxColumn column = new GridViewComboBoxColumn();
column.DataMemberBinding = new Binding
                        {
                            Path = new PropertyPath("Id"),
                            StringFormat = previousColumnDataMemberBinding.StringFormat
                        };
column.ItemsSource = MyItemsSources;
column.SelectedValueMemberPath = "Id";
column.DisplayMemberPath = previousColumnDataMemberBinding.Path.Path;
this.Columns.Add(column);


After running the program and adding this column I found all cells empty.
But on edit I see all values.
So currently I'm trying to implement the first solution form this post.
In xaml I haven't access to my column and I can't expose the ViewModel as a static resource from there.
And doing it from the code will make my control dependent from the concrete ViewModel which is unacceptable.

Can you suggest me some other solution or argue if I've been mistaken in my thoughts.

Thanks,
Tigran
0
Dimitrina
Telerik team
answered on 20 Sep 2013, 08:42 AM
Hello Tigran,

Would you please check if you have set the DataMemberBinding for GridViewComboBoxColumn to the correct property? 

If all the setting are set properly, may I ask you to isolate the issue in a demo project? You can also take a look at this blog post for a reference on how to isolate an issue. 

Looking forward to hearing from you.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Tigran
Top achievements
Rank 1
Answers by
Tigran
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or