Unique ComboBox filter for each row

2 posts, 0 answers
  1. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 18 Dec 2012 Link to this post

    Hi,

    I'm developing a time reporting system where the user reports time agains projects.
    A project is connected to one and only one customer, but a customer can have several projects.

    I have two GridViewComboBoxColumns, Project and Customer that are bound to ObservableCollections in the view model.
    When the user adds a new row, both ComboBoxes display all active projects and all customers.
    But then I need some smart filtering.
    If a user selects a project, the connected customer should automatically be set. That I have already fixed.
    The other way around is my problem,.
    If the user instead selects a customer, the Project ComboBox should be filtered so that only projects connected to that customer is displayed in the drop down.
    And of cource this should only affect the current row.

    I have seen some examples here on the forum about creating a collection on the business object that holds availale projects.
    But there can be hundreds of projects, and many many rows in the grid so it does not seem to be a good performance solution.

    Isn't there anyway I can set the ItemsSource for the ComboBox in code behind instead and filter it for each row?

    Regards,
    Håkan
  2. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 18 Dec 2012 Link to this post

    Hi again!

    I managed to solve this on my own.
    I set the ItemsSource to a subset of my view model collection in the PreparingCellForEdit event and it seems to work.

    Regards,
    Håkan
  3. DevCraft banner
Back to Top