Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to display data in a Datagrid based on cascading combo boxes MVVM

$
0
0

I have a datagrid that is being populated by using entity framework. The datagrid's item source is an observable collection:

The ViewModel has the following

        public ObservableCollection<Batch> BatchObsCol { get; set; }

The view has the data grid setup as below:

<DataGrid ...
ItemsSource="{Binding BatchObsCol}"/>

What I am wanting to do is have this data grid be filtered based on a number of combo box selections(4 to be exact).

Currently, each of my combo boxes are populated with IOrderedEnumerable objects. Each of the objects are set up to select only one of the fields in the BatchObsCol. Below is how the code is set up:

 //Items for Combo Boxes
public IOrderedEnumerable<string> cboListPartNumber { get; set; }
public IOrderedEnumerable<string> cboListTraceNumber { get; set; }
public IOrderedEnumerable<string> cboListPONumber { get; set; }
public IOrderedEnumerable<string> cboListInvoiceNumber { get; set; } 

//Inside the contructor
//extract single field and sort
cboListPartNumber = BatchObsCol.Select(b => b.PartNumber).OrderBy(b => b.ToString());
cboListTraceNumber = BatchObsCol.Select(t => t.TraceNumber).OrderBy(t => t.ToString());
cboListPONumber = BatchObsCol.Select(p => p.PurchaseOrderNumber).OrderBy(p => p.ToString());
cboListInvoiceNumber = BatchObsCol.Select(i => i.InvoiceNumber).OrderBy(i => i.ToString());
 

Currently, as it stands, all records are being shown in the datagrid. What I would like to do is have only records show according to multiple combo box selections. When one combo box is selected, I would like the other combo boxes to be filled only with items related to the selection within the previous combo box selection (Like a cascading combo box)

I am using MVVM...

Thank you for any help I might recieve


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>