Hello,
I would like to create a datagrid that provides a list of States as a XamComboEditor and another that provides a list of Cities within a State as a XamComboEditor. I am not sure how to accomplish this. Basically I would like the selected item of the States to filter the ItemsSource of my Cities combobox. Any thoughts?
Hi,
There are probably a couple of different ways to implement this functionality in your application.
Solution:
2. Check to see if the cell entering edit mode belongs to the City Field.
3. If so, apply a filter to the collection that contains city information.
I am attaching a sample as a proof-of-concept. Since you did not state the version of NetAdvantage for WPF you are using in your application, I used the latest and greatest 8.2. If you do not have 8.2, you will have to replace the references in the project
There are other ways to implement this functionality based on your data source. If your State object expose a nested collection of City objects, you can use a RelativeSource binding to retrieve the Cities in a particular State. For example, the Field that contains the City information would use the following EditorStyle:
<Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type igDP:DataRecordPresenter}}, Path=DataRecord.DataItem.State.Cities}" /> <Setter Property="DisplayMemberPath" Value="CityName" /></Style>
Sorry but that was not what i mean.My properties "tenMileRuns" and "gameNames", needs to be display'd in a combobox.Pseudo code:Public class Person{ public string Name{get;set;} public int age{get;set;} public DateTime[ tenMileRuns {get;set;} public List<string> gameNames {get;set;}}public class ShowPersons : Window{ public ShowPersons() { List<Person> persons = new List<Person>() { new Person(){Name = "John", age = 20, tenMileRuns = new DateTime[, gameNames = new List<string>{"LA","NY","CA", "MI"}, new Person(){............... AND SO ON }; /// DATAGRID and FIELD definitions dataGrid.DataSource = persons; }}
The XamDataGrid will not be able to insert the values directly in the ComboBoxes. This will be a form of hierarchy. You need to set the datasource of the ComboBoxes the collections of data - in your case : gameNames and tenMileRuns. You can see that i the XamFeatureBrowser -> Control Composition -> XamComboBoxEditor in DataRecord Cells.
Sorry but maybe is my example not clear....because you refering to a basic combobox in which the values in every row are the same.
Straightforward: I need a Column with a combobox with different values.
I'm trying to set the fieldsettings of a cell, but then gets that column in each row the same combobox-values
(If i can't bind it, i hardcode it, no problem).
Any idea's?
A cell does not expose a FieldSettings property, so I assume you are using the Cell.Field.FieldSettings. Since the FieldSettings property belongs to the Field object, all cells in that field will use the same combo box. Instead, you should be setting the Cell.EditorStyle and/or Cell.EditorType properties to use a different xamComboEditor in each cell.
The only problem I see here is a clash between the collection properties exposed by your data source and the functionality of the xamComboEditor. The xamComboEditor control allows your end users to select a single value; where-as the tenMileRuns property and gameNames property are nested collections within your Person entity. There is no way to convert between a single value selected by your end user and the corresponding collection property. For example, if you have a xamComboEditor that displays all the date times of a ten mile run, and your end user selects a single date, what's supposed to happen?
If the xamComboEditor is simply for read-only purposes, you can define the field layout yourself and leave out the fields that correspond to the collection properties. Then, you can add unbound fields to display the xamComboEditor with the values of the nested collections.
I admit, my example was not very well.I thought i could code something quick instead of a usefull practical sample.
I have a calculated result displayed in a datagrid. This result consist of links, and each link must have two frequencies (Tx/Rx). But first all these frequencies are calculated individually, so every link must have two comboboxe's which contain multiple calculated frequencies. And the user must select one Tx frequency and one Rx frequency from the list, for each link.
When can i "plugin" on the cell level to set the Cell.EditorStyle/EditoryType correctly?
You have to re-template the CellValuePresenter (where you want to have the two Combos -- Template property). It is easy by creating a style. You can find default styles of all the controls and parts in the DefaultStyles directory in the Infragistics folder on your computer.
Alex.