Separate ItemsSource for each newly added GridViewComboBoxColumn

5 posts, 0 answers
  1. Tigran
    Tigran avatar
    3 posts
    Member since:
    Sep 2013

    Posted 13 Sep 2013 Link to this post

    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

     
  2. Tigran
    Tigran avatar
    3 posts
    Member since:
    Sep 2013

    Posted 17 Sep 2013 Link to this post

    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.
  3. DevCraft banner
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 17 Sep 2013 Link to this post

    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 >>
  5. Tigran
    Tigran avatar
    3 posts
    Member since:
    Sep 2013

    Posted 18 Sep 2013 Link to this post

    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
  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 Sep 2013 Link to this post

    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 >>
Back to Top
DevCraft banner