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

Unique ComboBox filter for each row

1 Answer 38 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Håkan
Top achievements
Rank 1
Håkan asked on 18 Dec 2012, 08:37 AM
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

1 Answer, 1 is accepted

Sort by
0
Håkan
Top achievements
Rank 1
answered on 18 Dec 2012, 08:46 AM
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
Tags
GridView
Asked by
Håkan
Top achievements
Rank 1
Answers by
Håkan
Top achievements
Rank 1
Share this question
or